Skip to content

Instantly share code, notes, and snippets.

@eagleusb
Last active August 17, 2020 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eagleusb/fde2e521dda306e7d5656183820d1847 to your computer and use it in GitHub Desktop.
Save eagleusb/fde2e521dda306e7d5656183820d1847 to your computer and use it in GitHub Desktop.
Git Nifty Tips and Tricks

Git

Rewrite All Commits Author

pip3 install --user git-filter-repo
cat <<EOF > .mailmap
eagleusb <git@eagleusb.com> <capscale@foolul.net>
EOF

git filter-repo --mailmap .mailmap

Code Review

This is extensively copied or inspired from GitLab engineering processes.

The goal here is to have minimal set of efficient ways to ensure and improve collaboration within code reviews.

For Everyone

These are not just words :°)

  1. be kind.
  2. accept that many engineering decisions are opinions, discuss tradeoffs and reach consensus quickly.
  3. ask questions; don’t make demands
  4. ask for clarification
  5. avoid selective ownership of code. ("mine", "not mine", "yours")
  6. be explicit, remember people don’t always understand your intentions online
  7. be humble ("i’m not sure - let’s look it up")
  8. don’t use hyperbole ("always", "never", "endlessly", "nothing")
  9. be careful about the use of sarcasm
  10. consider one-on-one video call if there are too many misunderstandings and post a follow-up comment summarizing it

Merge Request Author

The responsibility to find the best solution and implement it lies with the merge request author.

  • general principles:
  1. it actually solves the problem it was meant to solve
  2. it does so in the most appropriate way
  3. it satisfies all requirements
  4. there are no remaining bugs, logical problems, uncovered edge cases, or known vulnerabilities
  • technical principles:
  1. re-read every line
  2. test your code locally
  3. write a test for every change (or as many as you can)
  4. write a clear description and update it after each feedback cycle

See More

Merge Request Reviewer

  • general principles:
  1. ensure good overall architecture
  2. ensure compliant code organization, consistency, and readability
  3. ensure separation of concerns and DRYness
  • technical principles:
  1. use conventionnal comments if possible
  2. read every line
  3. suggest alternative implementations but assume the author already considered them
  4. if you don't understand a piece of code, say so by asking
  5. approve the merge request and be responsible for it
  6. advise the author their merge request has been reviewed and approved

See More

Conventional Comments

These are verbs we can use to highlight some intent during merge requests reviews.

The format of comment is as simple as:

<verb>: <comment>

A simple example would be:

**praise**: conventional comments is awesome, let's use it

The current list of verbs and meanings is the following:

Verb Description
praise: highlight something positive. Do not leave false praise which can actually be damaging
nitpick: small, trivial, but necessary changes
suggestion: propose alternative(s) with in minde that author should have thought about it
issue: user facing problems, best with a suggestion to solve it
question: to ask clarification
thought: digressing idea(s) coming during the review
chore: chores that must be done before merging

Links

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