Cover art for Git-getpull: Quickly find the pull request that merged your commit to master by Andrew Warner

Git-getpull: Quickly find the pull request that merged your commit to master

Git-getpull: Quickly find the pull request that merged your commit to master Lyrics

Ideally git blame would give you all the context you need to determine why some code was written. But the reality is that no team is perfectly disciplined, and sometimes you're going to run across commits with cryptic or ambiguous messages ("bugfix," anyone?).

When a git commit message doesn't provide enough context, or provides context at the wrong level (too much what, too little why), it's useful to be able to find the GitHub pull request that merged that commit. Pull requests can contain code review comments, discussion over implementation details, before/after pictures of the UI, and more. Pull requests may also have many commits associated with them, which together give a clearer sense of the intended change.

The git-getpull utility allows you to find out which pull request merged a commit into master.

Installation

$ curl -o /usr/local/bin/git-getpull https://raw.github.com/a-warner/git-getpull/master/git-getpull && chmod +x /usr/local/bin/git-getpull

Usage

$ git getpull 42a3817c
https://github.com/rails/rails/pull/11195

Annotated Code!

Click the highlighted bits for more information.

#!/bin/sh

if [ -z "$1" ]; then
  echo "Usage: git getpull <SHA>"
  exit 1
elif [ -z "$(git rev-parse --git-dir 2>/dev/null)" ]; then
  echo "Not in a git directory"
  exit 1
else
  repository_path=$(git config --get remote.origin.url 2>/dev/null | \
   perl -lne 'print $1 if /(?:(?:https?:\/\/github.com\/)|:)(.*?).git/')
  pull_base_url=https://github.com/$repository_path/pull
  pull_id=$(git log $1..master --ancestry-path --merges --oneline 2>/dev/null \
  | tail -n 1 | perl -nle 'print $1 if /#(\d+)/')

  if [ -n "$pull_id" ]; then
    echo "$pull_base_url/$pull_id"
  else
    echo "Sorry, couldn't find that pull"
    exit 1
  fi
fi

How to Format Lyrics:

  • Type out all lyrics, even repeating song parts like the chorus
  • Lyrics should be broken down into individual lines
  • Use section headers above different song parts like [Verse], [Chorus], etc.
  • Use italics (<i>lyric</i>) and bold (<b>lyric</b>) to distinguish between different vocalists in the same song part
  • If you don’t understand a lyric, use [?]

To learn more, check out our transcription guide or visit our transcribers forum

About

Genius Annotation

Quickly find the GitHub pull request that merged your commit to master with git-getpull

Q&A

Find answers to frequently asked questions about the song and explore its deeper meaning

Comments