tracker-git 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.travis.yml CHANGED
@@ -1,4 +1,3 @@
1
1
  rvm:
2
2
  - 1.9.2
3
3
  - 1.9.3
4
- - jruby-19mode
data/README.md CHANGED
@@ -26,10 +26,16 @@ Or install it yourself as:
26
26
 
27
27
  ## Usage
28
28
 
29
- This gem will create a 'tracker' binary. Call that in your deploy script with the following environment variables set, and your finished stories will be updated to delivered.
29
+ This gem will create a 'tracker' binary. Call that in your deploy script with
30
+ the tracker id and access token as command line arguments, or with following
31
+ environment variables set, and your finished stories will be updated to
32
+ delivered.
30
33
 
31
- export tracker_token=abc123
32
- export tracker_project_id=123456
34
+ export TRACKER_PROJECT_ID=123456
35
+ export TRACKER_TOKEN=abc123
36
+
37
+ Optionally you can specify a specific git branch as the third command line
38
+ argument or with the GIT_BRANCH environment variable.
33
39
 
34
40
  ## Known Issues
35
41
 
data/bin/tracker CHANGED
@@ -6,11 +6,27 @@ rescue LoadError
6
6
  require 'tracker-git'
7
7
  end
8
8
 
9
- tracker_token = ENV['tracker_token']
10
- project_id = ENV['tracker_project_id']
9
+ project_id, tracker_token, git_branch = \
10
+ if [2, 3].include? ARGV.size
11
+ ARGV
12
+ else
13
+ [ENV['TRACKER_PROJECT_ID'], ENV['TRACKER_TOKEN'], ENV['GIT_BRANCH']]
14
+ end
15
+
16
+ unless tracker_token && project_id
17
+ puts <<-USAGE
18
+ Usage: Pass your pivotal tracker project id and access token on the command
19
+ line, e.g:
20
+ tracker 123456 abc123
21
+ or as an environment variable:
22
+ export TRACKER_PROJECT_ID=123456
23
+ export TRACKER_TOKEN=abc123
24
+ tracker
25
+ USAGE
26
+ exit(1)
27
+ end
11
28
 
12
29
  project = Tracker::Project.new(tracker_token, project_id)
13
30
  git = Tracker::Git.new
14
31
  deliverer = Tracker::Deliverer.new(project, git)
15
-
16
- deliverer.mark_as_delivered
32
+ deliverer.mark_as_delivered(git_branch)
@@ -6,9 +6,12 @@ module Tracker
6
6
  @git = git
7
7
  end
8
8
 
9
- def mark_as_delivered
9
+ def mark_as_delivered(branch = nil)
10
+ options = {}
11
+ options[:branch] = branch if branch
12
+
10
13
  project.finished.each do |story|
11
- if git.contains?(story.id)
14
+ if git.contains?(story.id, options)
12
15
  project.deliver(story)
13
16
  end
14
17
  end
@@ -2,7 +2,7 @@ module Tracker
2
2
  class Git
3
3
  def contains?(message, options = {})
4
4
  branch = options.fetch(:branch, "master")
5
- result = `git log --grep '#{message}' #{branch}`
5
+ result = `git log #{branch} --grep='#{message}'`
6
6
  result.length > 0
7
7
  end
8
8
  end
@@ -1,3 +1,3 @@
1
1
  module Tracker
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -11,15 +11,29 @@ describe Tracker::Deliverer do
11
11
  let(:git) { stub }
12
12
  let(:deliverer) { Tracker::Deliverer.new(project, git) }
13
13
 
14
- describe "mark_as_delivered" do
15
- it("should mark stories as delivered") do
16
- project.should_receive(:finished) { finished_stories }
17
- git.should_receive(:contains?).with(1) { true }
18
- git.should_receive(:contains?).with(2) { false }
19
- project.should_receive(:deliver).with(commited_story)
20
- project.should_not_receive(:deliver).with(uncommited_story)
14
+ describe '#mark_as_delivered' do
15
+ context 'when called without argument' do
16
+ it('should mark stories as delivered') do
17
+ project.should_receive(:finished) { finished_stories }
18
+ git.should_receive(:contains?).with(1, {}) { true }
19
+ git.should_receive(:contains?).with(2, {}) { false }
20
+ project.should_receive(:deliver).with(commited_story)
21
+ project.should_not_receive(:deliver).with(uncommited_story)
21
22
 
22
- deliverer.mark_as_delivered
23
+ deliverer.mark_as_delivered
24
+ end
25
+ end
26
+
27
+ context 'when given a specific branch' do
28
+ it('should mark stories as delivered') do
29
+ project.should_receive(:finished) { finished_stories }
30
+ git.should_receive(:contains?).with(1, {branch: 'develop'}) { true }
31
+ git.should_receive(:contains?).with(2, {branch: 'develop'}) { false }
32
+ project.should_receive(:deliver).with(commited_story)
33
+ project.should_not_receive(:deliver).with(uncommited_story)
34
+
35
+ deliverer.mark_as_delivered('develop')
36
+ end
23
37
  end
24
38
  end
25
39
 
data/spec/git_spec.rb CHANGED
@@ -4,7 +4,7 @@ describe Tracker::Git do
4
4
  describe "#search" do
5
5
  let(:message) { "[Finishes #123456]" }
6
6
  let(:branch) { "master" }
7
- let(:query) { "git log --grep '#{message}' #{branch}"}
7
+ let(:query) { "git log #{branch} --grep='#{message}'"}
8
8
  let(:result) { "Some git message" }
9
9
 
10
10
  before do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tracker-git
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-27 00:00:00.000000000 Z
12
+ date: 2012-10-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pivotal-tracker
@@ -116,7 +116,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
116
116
  version: '0'
117
117
  segments:
118
118
  - 0
119
- hash: -4298825467225277464
119
+ hash: 531834068982296945
120
120
  required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  none: false
122
122
  requirements:
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  version: '0'
126
126
  segments:
127
127
  - 0
128
- hash: -4298825467225277464
128
+ hash: 531834068982296945
129
129
  requirements: []
130
130
  rubyforge_project:
131
131
  rubygems_version: 1.8.24