Posted 11 months ago. Visible to the public.

Bash script to list commits by Pivotal Tracker ID

The main benefit of our convention to prefix commits by their corresponding Pivotal Tracker ID is that we can easily detect commits that belong to the same story. You can either do that manually or use the bash script below by copying it somewhere to your .bashrc.

Copy
# Usage: ptcommits #123456 function ptcommits { if test "$1" then local PTID=$(echo "$1" | grep "[0-9]*" -o) # Allow URLs git log --oneline | grep "$PTID" | grep "^[a-z0-9]*" -o | xargs --no-run-if-empty git show $2 $3 $4 else echo "Please specify a Pivotal Tracker story ID" fi } alias ptcommit='ptcommits'

Now you can use use the command like this: ptcommits 165086636 --stat. Up to three arguments are passed to git show. Example output:

Copy
commit 048054b1df87576f7c59cc0161cc331c44d2ea6b Author: Foo Bar <foo@bar.com> Date: Fri Apr 5 14:24:24 2019 +0200 [#165086636] My Pivotal Tracker Title app/assets/javascripts/test.js.coffee | 22 ++++++++++++++++++++++ app/models/test.rb | 30 ++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 0 deletions(-)

Caveats

  • ptcommits #<STORY_ID> does not work, since your shell with ignore STORY_ID (it is marked as a comment). Use ptcommits '#<STORY_ID>' instead.

See also

Does your version of Ruby on Rails still receive security updates?
Rails LTS provides security patches for old versions of Ruby on Rails (3.2 and 2.3).

Owner of this card:

Avatar
Michael Leimstädtner
Last edit:
11 days ago
by Michael Leimstädtner
Keywords:
bookmarklet
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Michael Leimstädtner to makandra dev
This website uses short-lived cookies to improve usability.
Accept or learn more