-
Notifications
You must be signed in to change notification settings - Fork 60
Open
Labels
Points: 30open-for-allAny one can work on it without getting assigned, every PR can mergeAny one can work on it without getting assigned, every PR can merge
Description
FOSS β Third Issue π
Git Commit Stash and Cherry Pick
Issue Type
FOSS Β· Intermediate Β· Open for All π
Contribution Rules β
- Work only on foss and foss-task-03 branch
- Original content only (No AI usage, otherwise Straight PR Rejection)
Objective
Learn how to use git stash and git cherry-pick to safely complete a real calculation feature when work is blocked by upstream changes.
Scenario
A calculator function is split into two parts:
- Part A β Validation + GST calculation
- Part B β Discount logic
Part B already exists in another branch (foss-task-03).
You must safely combine both parts into the working foss branch.
Setup
Branch foss-task-03 contains calculator.cpp with the required implemented part of the function:
#include <iostream>
using namespace std;
/*
Function: calculateFinalAmount
Purpose : Calculates final payable amount after tax and discount.
*/
double calculateFinalAmount(double amount, int customerType) {
//Part A
//Part B
}
int main() {
double amount;
int type;
cout << "Enter bill amount: ";
cin >> amount;
cout << "Enter customer type (1-Regular, 2-Premium): ";
cin >> type;
double payable = calculateFinalAmount(amount, type);
cout << "Final Payable Amount: " << payable << endl;
return 0;
}Implement Part A as follow:
Check if amount is valid, if less than or equal to 0, print "Invalid Amount" and return.
Otherwise make two variables tax and total. tax will be 18% of the amount and total will be summation of tax and amount.
Steps
- Checkout the
fossbranch. - Copy the above code inside the file
calculator.cppplaced insidetask-03/. Implement Part A only, by your own (do not commit) - Stash changes using
git stash push -m "calculator-part-a" - Check out the
foss-task-03branch. (You may need to fetch it by runninggit switch -c foss-task-03 origin/foss-task-03) - Cherry-pick Part B commit from foss-task-03, the lastest commit on this branch.
- Pop stash and resolve conflicts if any.
- Make a folder of your own
<githubId>/inside thetask-03/folder, place yourcalculator.cppfile inside there. - Commit final calculator function.
Mandatory PR Requirement
git log --oneline --graph --all
git stash list
Attach screenshots.
PR Submission
- Part A and Part B both exist
- Cherry-pick and stash used correctly
- Screenshots attached
- Answer the hidden question asked during the task.
Metadata
Metadata
Assignees
Labels
Points: 30open-for-allAny one can work on it without getting assigned, every PR can mergeAny one can work on it without getting assigned, every PR can merge