For the sake of keeping our repo clean, below are our agreed upon guidelines for contributing to Boojo.
- Commit subject lines should be informative as to what was changed.
- Good commit:
front-end/login: fix login failing due to cors
- Bad commit:
cors fix
- Good commit:
- Commit messages should be no wider than 72 characters. This is a limitation of
Git.
- If you use the command line to commit, you can switch your text editor to
vim using the command
git config core.editor "vim"
and add the lineau FileType gitcommit setlocal tw=72
to your.vimrc
.
- If you use the command line to commit, you can switch your text editor to
vim using the command
- Commit messages follow the format of:
- Subject Line
- Blank Line
- Message Body
- Prefix all commit messages with the section of the software that was modified. If multiple sections were modified, use the prefix for the file/folder that the commit focuses the most on.
- End all prefixes with
:
. - Do not use a
.
at the end of the subject line. - Message bodies are not always neccessary for small commits such as formatting changes, but are required on large commits that change functionality, or fix non-trivial bugs. Make sure to give a high level overview of what you changed and potentially why you changed it. If you do it right, you can use this message as the body of your pull request.
- Use of capital letters in the subject line is allowed.
Below is an example of a good commit message:
front-end/login: fix login failing due to cors
Due to changes in ab638c4 making CORS more strict, our login began
failing for users that weren't already logged in. This fixes the issue
by moving our backend server to the same TLD as our front-end server.
Protip: Use git commit
instead of git commit -m
or you will suffer.
One commit should encapsulate one change. This means that if there are multiple seperate bugs, each bug will get their own commit. Likewise, each added feature or discrete change should be a seperate commit.
The reason this is done is to prevent sprawl where multiple changes are squashed into one commit. This will make it easier to revert a single commit if the need arises without having to worry about accidentally reverting other wanted changes.
It is alright for one pull request to have multiple commits.
Often times you will need to amend commits because you missed something, formatting is off, or there is a bug. To avoid making micro-commits or unncessarily spreading changes across commits, you can squash commits.
Here's what to do in these situations:
- There is a mistake in my last commit.
-
- Stage your changes and run
git commit --amend
. - If you've already pushed to your repo, use
git push -f
to push.
- Stage your changes and run
-
- There is a mistake in any other commit.
-
- Run
git log
and copy the commit hash of the commit you want to fix. - Stage your changes and run
git commit --fixup=<copied hash>
. - Run
git rebase -i --autosquash <copied hash>~1
. - If you have already pushed, push again with
git push -f
.
- Run
-
- Fork the repository.
- Clone your forked repo to your machine.
- Run
git remote add prod https://github.com/cse-112-sp22-group1/cse112-sp22-group1.git
- Before you start making new changes, pull from production with
git pull prod
- Checkout a new branch for the change you are working on with
git checkout -b <feature>
- When you are done making changes, push this branch to your fork with
git push --set-upstream origin <feature>
- Open a pull request on the team repo. If you wrote good commit messages, you can use their contents for the pull request.
- Two reviewers will check your pull request before merging it into the appropriate branch.
While pull requests can contain multiple commits, all commits must be related. Each pull request should implement a closely related set of changes.