Skip to content

Instantly share code, notes, and snippets.

@odrotbohm
Last active December 14, 2015 16:39
Show Gist options
  • Save odrotbohm/5116701 to your computer and use it in GitHub Desktop.
Save odrotbohm/5116701 to your computer and use it in GitHub Desktop.
A loose collection of development guidelines that I apply to my day to day work. Will be updated continuously.

Apply code cleanups

Code formatting applied - Code is auto-formatted by using the project's formatter to avoid formatting related changes polluting the changeset. This includes using Eclipse Save Actions such as organizing imports.

Commits include tests

Commits are backed by tests - Every commit includes test cases to verify the change fixing an issue or the code working generally. This ensures we continuously improve the code coverage even if the original codebase is not exhaustively covered by tests.

Commit refs ticktet

Every commit is referencing a ticket - To give a change a broader context every change to the code base refers to a ticket in either JIRA or the GitHub bug tracker. This allows traceability and a quick zoom in or out in terms of high level requirements and low level necessary code changes.

Linear history

Keep version history linear - I am trying to avoid merge commits as much as possible as they usually introduce noise into the code history. I usually merge pull requests using the following pattern:

  1. git checkout -b ${ticketId}
  2. curl ${pullRequestUrl}.patch | git am --ignore-whitespace - Pulls commits into the feature branch
  3. git rebase -i ${base-sha1} - Squash commits into one
  4. Polish commit, apply formatting etc.
  5. git checkout master
  6. git merge ${ticketId}
  7. git push origin master

This assures we stick to the single commit rule and preserve authorship of the original author.

Single commit

Strive for a single commit per ticket - As aticket forms a unit of work I strive for a single commit to fix or implement a ticket. In case I know the ticket is a bigger one I might create a feature-branch for that ticket and sum up commits on that one. Before merging the commits back into the main line I can then squash them into a single commit so that I end up with the rule applied in my main code line.

Consistent commit message

Use a consistent structure for commit comments - I generally use the following pattern:

${ticketId} - ${summary}

${details}

Keeping the ticket id in the summary line allows quickly finding out about the ticket that describes the requirements for the change on a high level. I don't necessarily manually line-break the details section and also prefer completeness of the summary line over sticking with the 80 character limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment