Giter Club home page Giter Club logo

git_tracker's Introduction

GitTracker

Gem Version Build Status Maintainability Test Coverage

GitTracker, or git-tracker, is a Git hook that will scan your current branch name looking for something it recognizes as a Pivotal Tracker story number. If it finds one, it will automagically add it, in the special format, to your commit message.

Installation

1) Install the git-tracker binary

You need to get the git-tracker binary onto your system.

  • via Homebrew 🍻 (preferred)

    $ brew install git-tracker
  • via RubyGems 😔 (if you must)

    $ gem install git_tracker

2) Initialize the hook

Then you need to initialize the git hook into each local Git repository where you want to use it.

# from inside a local Git repository
# for example: /path/to/repo/
$ git tracker init

This will put the prepare-commit-msg hook in the /path/to/repo/.git/hooks directory and make it executable.

NOTE: The hook needs to be initialized just once for each repository in which you will use it.

Usage

With the hook initialized in a repository, create branches being sure to include the Pivotal Tracker story number in the branch name.

$ git checkout -b a_useful_and_helpful_name_8675309

When you commit, Git will fire the hook which will find the story number in the branch name and prepare your commit message so that it includes the story number in the special Pivotal Tracker syntax.

# on branch named `best_feature_ever-8675309`
$ git commit

Will result in a commit message something like: (notice the two empty lines at the top)

[#8675309]
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch best_feature_ever-8675309
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
# new file:   feature.rb
#

You should then add a useful and responsible commit message. ❤️

Passing commit messages via command line

If you pass a commit message on the command line the hook will still add the story number, preceded by an empty line, to the end of your message.

# on branch named `best_feature_ever-8675309`
$ git commit -m'Look at this rad code, yo!'

Results in this commit message:

Look at this rad code, yo!

[#8675309]

However, if you include the story number in the Pivotal Tracker format within your commit message, the hook will do nothing.

# on branch named `best_feature_ever-8675309`
$ git commit -m'[#8675309] Look at this rad code, yo!'

Results in this commit message:

[#8675309] Look at this rad code, yo!

Keywords

You can use the custom keywords that Pivotal Tracker provides with the API.

The keywords are fixed, completed, finished, and delivered in square brackets. You may also use different cases and forms of these verbs, such as Fix or FIXES.

If you use those keywords in your commit message, the keyword will be prepended to the story ID in the commit message.

For example:

# on branch named `bug/redis_connection_not_initializing_8675309`
$ git commit -am "Change the redis connection string [Fixes]"

Results in this commit message:

Change the redis connection string [Fixes]

[Fixes #8675309]

Valid branch names

GitTracker allows you to include the story number any where in the branch name, optionally prefixing it with a hash (#). Examples:

  • best_feature_ever_#8675309
  • best-feature-ever-8675309
  • 8675309_best_feature_ever
  • #8675309-best-feature-ever
  • your_name/8675309_best_feature_ever
  • your_name/#8675309_best_feature_ever

Contributing :octocat:

  1. Fork it
  2. Create your feature branch (git checkout -b my_new_feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my_new_feature)
  5. Create new Pull Request

git_tracker's People

Contributors

bomberstudios avatar craigwilliams avatar flats avatar kensodev avatar stevenharman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

git_tracker's Issues

Exception whenever I try to run git_tracker

I get the following when I run git tracker:

♬  cd Code/project; git tracker
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `gem_original_require': /Users/tom/.rvm/gems/ruby-1.9.3-p125@elocal/gems/git_tracker-1.3.1/lib/git_tracker/branch.rb:7: undefined (?...) sequence: /#?(?<number>\d+)/ (SyntaxError)
/Users/tom/.rvm/gems/ruby-1.9.3-p125@elocal/gems/git_tracker-1.3.1/lib/git_tracker/branch.rb:15: undefined (?...) sequence: /refs\/heads\/(?<name>.+)/
  from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `require'
  from /Users/tom/.rvm/gems/ruby-1.9.3-p125@elocal/gems/git_tracker-1.3.1/lib/git_tracker/prepare_commit_message.rb:1
  from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
  from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `require'
  from /Users/tom/.rvm/gems/ruby-1.9.3-p125@elocal/gems/git_tracker-1.3.1/lib/git_tracker.rb:2
  from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
  from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `require'
  from /Users/tom/.rvm/gems/ruby-1.9.3-p125@elocal/gems/git_tracker-1.3.1/bin/git-tracker:3
  from /Users/tom/.rvm/gems/ruby-1.9.3-p125@elocal/bin/git-tracker:19:in `load'
  from /Users/tom/.rvm/gems/ruby-1.9.3-p125@elocal/bin/git-tracker:19
  from /Users/tom/.rvm/gems/ruby-1.9.3-p125@global/bin/ruby_bundler_wrapper:23

It began happening when I mucked with my RVM configuration, updated using rvm get stable and it did some shit to my .zshrc...

Support for other Tracking Systems

I am on a project that uses JIRA today. Their story format is XYZ-123, where XYZ is a project prefix and 123 is the story number. In my work, I would create branch sparks/xyz-123 and make all the commits prefixed thus:

[XYZ-123] Add sweet feature

I think the change that would work best would be to allow the user to specify the regex in init, eg.:

git tracker init '[A-Z]{2,5}-[0-9]{1,5}'
or if they're project specific...
git tracker init 'XYZ-[0-9]{1,5}'

Using the git-tracker hook breaks git rebase --interactive

When I try to git rebase --interactive, I'm met with this ugly and uninformative error:

fatal: ref HEAD is not a symbolic ref

To fix this, I simply removed the pre-commit hook that git-tracker provided. I'm guessing that editing the COMMIT_EDITMSG file is what's breaking the rebase.

Here's the full output: https://gist.github.com/d38f1e2d2ec9bc480b6f

And my processed is described in detail at http://stackoverflow.com/questions/10488655/i-cant-git-rebase-interactive-anymore

Let me know if I may be of any further assistance. I can't really use this wonderful plugin until this is fixed, as rebase --interactive is an integral part of my git workflow.

Cygwin?

Are there any instructions for installing this manually? I'm hoping you can point me at the binaries and the hooks locations to get this working in cygwin.

I did get ruby gems installed on cygwin, and I successfully ran gem install git_tracker but something is not registering.

$ git tracker init
git: 'tracker' is not a git command. See 'git --help'.

Thanks for the help

git tracker init or git-tracker init ?

Hi,

I think there might be a typo in your readme. git tracker does not seem to be a git command, but the Readme advises users to type git tracker init. It should reead git-tracker init.

Also, for newbyes using rbenv, you might want to recall them to call rbenv rehash after installing git-tracker via gem install.

Integration with Sprint.ly

I am working with Sprint.ly on several client projects.

The Sprintly integration around github consists on keywords, and unlike Pivotal tracker, it's not enough to have the issue ID in the commit message, you need to ref #111 inorder to make it into the comments.

I want to implement this using a plugin system that build the commit message, this way it's extendable in the future.

I am thinking of something like

git-tracker install #defaults to Pivotal Tracker
git-tracker install sprintly #goes into sprintly mode

Is this something you would like to see a pull request for?

Tower Support

I had to PATH="$PATH:/usr/local/bin" to the top of the hook file for Tower Git client to recognize the git-tracker command.

Submodule support

This doesn't behave well when trying to init in a repository that is a submodule.

I had to git clone my submodule repo, then init in there and copy the created hook to the proper location in ../parent/.git/modules/repo/hooks/

$ git tracker init
/var/lib/gems/2.1.0/gems/git_tracker-1.6.3/lib/git_tracker/hook.rb:20:in `initialize': Not a directory @ rb_sysopen - /home/user/parent/repo/.git/hooks/prepare-commit-msg (Errno::ENO
TDIR)
        from /var/lib/gems/2.1.0/gems/git_tracker-1.6.3/lib/git_tracker/hook.rb:20:in `open'
        from /var/lib/gems/2.1.0/gems/git_tracker-1.6.3/lib/git_tracker/hook.rb:20:in `write'
        from /var/lib/gems/2.1.0/gems/git_tracker-1.6.3/lib/git_tracker/hook.rb:12:in `init_at'
        from /var/lib/gems/2.1.0/gems/git_tracker-1.6.3/lib/git_tracker/hook.rb:8:in `init'
        from /var/lib/gems/2.1.0/gems/git_tracker-1.6.3/lib/git_tracker/runner.rb:19:in `init'
        from /var/lib/gems/2.1.0/gems/git_tracker-1.6.3/lib/git_tracker/runner.rb:11:in `execute'
        from /var/lib/gems/2.1.0/gems/git_tracker-1.6.3/bin/git-tracker:4:in `<top (required)>'
        from /usr/local/bin/git-tracker:23:in `load'
        from /usr/local/bin/git-tracker:23:in `<main>'

"Ignoring debase" error

I have just recently started getting the following error when I try to use git commit with a git-tracker enabled repo:

Ignoring debase-0.2.2.beta11 because its extensions are not built.  Try: gem pristine debase --version 0.2.2.beta11
Ignoring debase-0.2.2.beta10 because its extensions are not built.  Try: gem pristine debase --version 0.2.2.beta10
Ignoring debase-0.2.1 because its extensions are not built.  Try: gem pristine debase --version 0.2.1

My Ruby version is: ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]

Running the suggested commands did not solve anything and I am unsure what else to do.

Commits break when git-tracker can't find the right Ruby

I've installed this awesome plugin with Homebrew, and I now have a globally-available command named git-tracker. Pretty cool!

The only time I ever find fault with it is when I'm using git inside other programs or plugins, like a Thor script that executes shell commands...

Here's an example output from when I try to run Git commands inside another Ruby (using Thor) process:

♬  rain on stage
Making it rain on stage...
No version type detected, assuming you meant '--patch' (as it is default)
executing... git commit -m '[RELEASE][stage] Update release tag for stage to rel_1.1.553' /Users/necromancer/Sites/elocal.com/config/versions.yml
Gemfile syntax error:
/Users/necromancer/Sites/elocal.com/Gemfile:22: syntax error, unexpected ':', expecting $end
gem 'thor', require: false
                    ^
executing... git push origin master
^CKilled by signal 2.
/Users/necromancer/Sites/elocal.com/vendor/gems/gems/activesupport-3.2.13/lib/active_support/core_ext/kernel/agnostics.rb:7:in ``': Interrupt
    from /Users/necromancer/Sites/elocal.com/vendor/gems/gems/activesupport-3.2.13/lib/active_support/core_ext/kernel/agnostics.rb:7:in ``'
    from /Users/necromancer/Sites/elocal.com/vendor/gems/bundler/gems/rain-5befc3a4ebca/lib/rain/git_tools.rb:88:in `run_cmd'
    from /Users/necromancer/Sites/elocal.com/vendor/gems/bundler/gems/rain-5befc3a4ebca/lib/rain/git_tools.rb:112:in `update_release_tag'
    from /Users/necromancer/Sites/elocal.com/vendor/gems/bundler/gems/rain-5befc3a4ebca/lib/rain/deployer.rb:23:in `on'
    from /Users/necromancer/Sites/elocal.com/vendor/gems/gems/thor-0.17.0/lib/thor/task.rb:27:in `run'
    from /Users/necromancer/Sites/elocal.com/vendor/gems/gems/thor-0.17.0/lib/thor/invocation.rb:120:in `invoke_task'
    from /Users/necromancer/Sites/elocal.com/vendor/gems/gems/thor-0.17.0/lib/thor.rb:344:in `dispatch'
    from /Users/necromancer/Sites/elocal.com/vendor/gems/gems/thor-0.17.0/lib/thor/base.rb:434:in `start'
    from /Users/necromancer/Sites/elocal.com/vendor/gems/bundler/gems/rain-5befc3a4ebca/bin/rain:11:in `<top (required)>'
    from /Users/necromancer/Sites/elocal.com/bin/rain:16:in `load'
    from /Users/necromancer/Sites/elocal.com/bin/rain:16:in `<main>'

Not sure if you guys had to deal with it in any other capacity, or if there was a way I should be calling Git commands in my deployment tool that would mitigate this issue?

Support for Ruby 1.8

Not only for older code bases, but this will be required if you wish to install and run the hook on Vanilla OS X (via Homebrew, for example).

wrong number of arguments

Hi there

I've installed git-tracker via homebrew. all interaction with it fails with the given error message:

/usr/local/bin/git-tracker:205:in `execute': wrong number of arguments (0 for 1) (ArgumentError)
    from /usr/local/bin/git-tracker:205

I was able to run git-tracker install - but what's next?

What commands can be run? I've tried with check and some more, but nothing works.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.