Contributing Guide - solvingbigfoot/hello-world GitHub Wiki
If you feel like contributing, please do so! Fork the project and open a pull request.
This is a Git Style Guide inspired by How to Get Your Change Into the Linux Kernel, the git man pages and various practices popular among the community.
-
FATHOM5 uses Trunk Based Development and all branches should comply with the branching model described here.
-
When branching choose short and descriptive names:
# good $ git checkout -b oauth-migration # bad - too vague $ git checkout -b login_fix
-
Use hyphens to separate words.
-
When several people are working on the same feature, it might be convenient to have personal feature branches and a team-wide feature branch. Use the following naming convention:
$ git checkout -b feature-a/master # team-wide branch $ git checkout -b feature-a/maria # Maria's personal branch $ git checkout -b feature-a/nick # Nick's personal branch
Merge at will the personal branches to the team-wide branch (see "Merging"). Rather quickly, the team-wide branch will be merged to "master".
-
Delete your branch from the upstream repository after it's merged, unless there is a specific reason not to.
Tip: Use the following command while being on "master", to list merged branches:
$ git branch --merged | grep -v "\*"
-
Each commit should be a single logical change. Don't make several logical changes in one commit. For example, if a patch fixes a bug and optimizes the performance of a feature, split it into two separate commits.
Tip: Use
git add -p
to interactively stage specific portions of the modified files. -
Don't split a single logical change into several commits. For example, the implementation of a feature and the corresponding tests should be in the same commit.
-
Commit early and often. Small, self-contained commits are easier to understand and revert when something goes wrong.
-
Commits should be ordered logically. For example, if commit X depends on changes done in commit Y, then commit Y should come before commit X.
Note: While working alone on a local branch, it's
fine to use commits as temporary snapshots of your work. However, it still
holds true that you should apply all of the above before merging it. To change
work on a local dev branch into a compliant set of logical changes use
git rebase -i HEAD~N
where N
is the number of commits back in your history that
need review. Use this git rebase link understand
effective rebasing and squash
small commits into logical changes.
-
Use the editor, not the command line, when writing a commit message:
# good $ git commit # bad $ git commit -m "Quick fix"
Committing from the terminal encourages a mindset of having to fit everything in a single line which usually results in non-informative, ambiguous commit messages.
-
Each commit message consists of a header (comprised of a type, scope, and subject) and a message.
# Note: This comment, and those that follow should not be # included in any commit. # Header format: <type>(<scope>): <subject> # Types are, feature, refactor, bug, task # Scope describes what the change affects. # Subject succinctly describes the change. # Message provides more info to keep the team aligned.
- Header examples:
- story(auth): Enable single signon
- refactor(api): Require user token when accessing api/users
- test(main): Raised test coverage to 95%
- task(docs): Update README.md
- bug(home page): Fix catastrophic bug when scrolling on IOS
- Header examples:
Type | Desc |
---|---|
story | Commit related to implementing a story. |
refactor | Commit that is not a feature but changes the existing code. |
test | Commit that expands test coverage for the code. |
bug | Commit that fixes a bug or fault. |
task | Commit that does not change the meaning of existing code; e.g. updating docs. |
Scopes describe the area or feature the change affects. Deciding what to put here can be a bit fuzzy so here's some suggestions:
- Use concise scope values.
- Try to use consistent scope values between commits.
The subject element should be descriptive yet succinct. Ideally, it should be no longer than 50 characters. It should be capitalized and written in imperative present tense. It should not end with a period since it is effectively the commit title:
# good - imperative present tense, capitalized, fewer than 50 characters
feature(database): Mark huge records as obsolete
# bad - wrong tense and too long
fix(ActiveModel): Error deprecation messages failing when AR was used outside of Rails.
-
After the header there should be a blank line followed by a more thorough description. It should be wrapped to 72 characters and explain why the change is needed, how it addresses the issue and what side-effects it might have.
-
The Message should also provide any pointers to related resources (eg. link to the corresponding issue in a bug tracker):
Short (50 chars or fewer) summary of changes More detailed explanatory text, if necessary. Wrap it to 72 characters. In some contexts, the first line is treated as the subject of an email and the rest of the text as the body. The blank line separating the summary from the body is critical (unless you omit the body entirely); tools like rebase can get confused if you run the two together. Further paragraphs come after blank lines. - Bullet points are okay, too - Use a hyphen or an asterisk for the bullet, followed by a single space, with blank lines in between The pointers to your related resources can serve as a footer for your commit message. Here is an example that is referencing issues in a bug tracker: Resolves: #56, #78 See also: #12, #34
-
Ultimately, when writing a commit message, think about what you would need to know if you run across the commit in a year from now.
-
If a commit A depends on commit B, the dependency should be stated in the message of commit A. Use the SHA1 when referring to commits.
Similarly, if commit A solves a bug introduced by commit B, it should also be stated in the message of commit A.
-
If a commit is going to be squashed to another commit use the
--squash
and--fixup
flags respectively, in order to make the intention clear:$ git commit --squash f387cab2
-
Do not rewrite published history. The repository's history is valuable in its own right and it is very important to be able to tell what actually happened. Altering published history is a common source of problems for anyone working on the project.
-
However, there are cases where rewriting history is legitimate. These are when:
-
You are the only one working on the branch and it is not being reviewed.
-
You want to tidy up your branch (eg. squash commits) and/or rebase it onto the "master" in order to merge it later.
That said, never rewrite the history of the "master" branch or any other special branches (ie. used by production or CI servers).
-
-
Keep the history clean and simple. Just before you merge your branch:
-
Make sure it conforms to the style guide and perform any needed actions if it doesn't (squash/reorder commits, reword messages etc.)
-
Rebase it onto the branch it's going to be merged to:
[my-branch] $ git fetch [my-branch] $ git rebase origin/master # if rebase is successful then `checkout master` # then merge using the --no-ff option as described below
This results in a branch that can be applied directly to the end of the "master" branch and results in a very simple history.
(Note: This strategy is better suited for projects with short-running branches. Otherwise it might be better to occassionally merge the "master" branch instead of rebasing onto it.)
-
-
When we merge, we are pulling changes from a development branch into the master branch. So you must
checkout master
before merging. If your branch includes more than one commit, do not merge with a fast-forward:# good - ensures that a merge commit is created $ git merge --no-ff my-branch # bad $ git merge my-branch
The basic syntax for a Smart Commit message is:
<ignored text> <ISSUE_KEY> <ignored text> #<COMMAND> <optional COMMAND_ARGUMENTS>
Any text between the issue key and the command is ignored.
Description | Adds a comment to a Jira Software issue. |
---|---|
Syntax | ISSUE_KEY #comment <comment_string> |
Example | JRA-34 #comment corrected indent issue |
Notes | The committer's email address must match the email address of a single Jira Software user with permission to comment on issues in that particular project. |
Description | Transitions aJira Software issue to a particular workflow state. |
---|---|
Syntax | <ISSUE_KEY> #<transition_name> #comment <comment_string> |
Example | JRA-090 #done #comment Fixed this today |
#to-do | Changes the workflow of the issue to "To Do" |
#in-progress | Changes the workflow of the issue to "In Progress" |
#done | Changes the workflow of the issue to "Done" |
-
There are various workflows and each one has its strengths and weaknesses. Whether a workflow fits your case, depends on the team, the project and your development procedures.
That said, it is important to actually choose a workflow and stick with it.
-
Be consistent. This is related to the workflow but also expands to things like commit messages, branch names and tags. Having a consistent style throughout the repository makes it easy to understand what is going on by looking at the log, a commit message etc.
-
Test before you merge. Do not merge half-done work.
-
Use annotated tags for marking releases or other important points in the history. Prefer lightweight tags for personal use, such as to bookmark commits for future reference.
-
Keep your repositories in good shape by performing maintenance tasks occasionally:
This work is licensed under a Creative Commons Attribution 4.0 International license.
Several of the ideas here were annotated by Agis Anastasopoulos / @agisanast / http://agis.io ... and contributors!