Skip to content

Contributing to 42FileChecker

Jules Lasne (jlasne) edited this page Dec 2, 2016 · 30 revisions

If you want to fix or to improve the 42FileChecker, follow the guide lines bellow, or if you want your own unit testing framework to be integrated in the 42FileChecker, just let me know :-)

The 42FC team is actually expanding. If you want to join us or contribute, contact us !

1. Fork and clone

Fork the repository with your account by clicking on the button Fork in the top-right corner of the page. Then, clone your freshly forked repository to your machine:

git clone https://github.com/YOUR-USERNAME/42FileChecker  #https
#or
git clone git@github.com:YOUR-USERNAME/42FileChecker      #ssl
2. Create a branch

Create a new branch from master (e.g. named bugfix--segfault-libft) to avoid the script to try updating itself:

git checkout -b bugfix--segfault-libft
3. Commit and push

Update code, make a review code, commit changes and push them:

git add -N .     #make sure new files are taken into account during your review
git add -p       #review code, type (y)es or (n)o to keep changes for committing
git commit -v    #commit with a title (first line) and more info on new lines
git push origin HEAD:bugfix--segfault-libft
4. Make a Pull Request

Go to your repository on Github and click on the green button New pull request. Let the default base fork: jgigault/42FileChecker and base branch: bugfix--segfault-libft, and compare to your freshly pushed branch. Once base and HEAD are both selected, you can preview your changes bellow. Click on the green button Create pull request.

A Pull Request allows us to discuss about your changes and to improve them together. You can still commit and push new changes, that will appear in the same Pull Request. You also can add me as contributor to your repository to allow me push to your branch.

5. Pull and rebase the Pull Request

Once changes are terminated and approved by me, make sure your branch is up to date. Add the original remote repository (choose a name for it, e.g.: jgigault):

git remote add jgigault https://github.com/jgigault/42FileChecker.git

Then, get the latest changes from jgigault/42FileChecker (fetch) and merge the master branch with your local branch:

git fetch jgigault
git merge jgigault/master

Once your repository is synced with the original, rebase all your commits together (see the tip bellow Rebasing a Pull Request) and push to your repository (you must force push if you rebased):

git push -f origin master

Finally, let me merge with the orginal master branch :-)


Tips

Rebasing a Pull Request

Rebasing consists in rewriting and/or grouping a number of commits, to make them clean or more explicit. Suppose you have these 5 latest dirty commits in a branch called patch-1:

git log --oneline

94b2ae8 finally ok
60fdff5 small changes
fd5b463 fix f***ing segfault
6fe7487 use ft_memmove instead of ft_putchar
636da7b first commit
...

We want to group them in a single one commit, and to rename it properly with bug fix: segfault on libft. First, run git rebase in interactive mode and specify the number of commits you want to rebase (here is 5):

git rebase -i HEAD~5

HEAD~5 means the last 5 commits from HEAD (the most recent). It opens the editor that is configured for git (vim by default), and displays a list of instructions, one per commit message:

pick 636da7b first commit
pick 6fe7487 use ft_memmove instead of ft_putchar
pick fd5b463 fix f***ing segfault
pick 60fdff5 small changes
pick 94b2ae8 finally ok

The commits are sorted from oldest to newest. The first word of each line is a git command (pick by default). There are 6 available commands that are described just below in the same screen. Suppose you know what each commit means and that you don't care about what message they contain, the simplest way to group them in a single one and to rename it properly, is to use the command reword for the first commit (allowing you to change the message) and fixup for all others (keeping changes trough the first commit but removing the messages), like below:

reword 636da7b first commit
fixup 6fe7487 use ft_memmove instead of ft_putchar
fixup fd5b463 fix f***ing segfault
fixup 60fdff5 small changes
fixup 94b2ae8 finally ok

Now, save and quit the editor, a new editor screen is opened with the first commit message:

first commit

Edit the message properly (the first line is the title of the commit, you can add more info by adding new lines), e.g.:

bug fix: segfault on libft

that commit fixes a bad behavior in libft resulting in a segfault

Again, save and quit the editor. When everything is OK, you get a success message:

Successfully rebased and updated refs/heads/patch-1.

Finally, you must use force push to push to your remote branch because you rewrote the History (note the use of the capital). By default, git will refuse your changes because the local branch does not correspond any more with the remote one. Just run:

git push -f HEAD:patch-1

(Note: Sometimes you would have to resolve conflicts, like when using the command git pull --rebase... a case that will be part of a full other tip)