tracker-git 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 73a17722e09a98741a2b270a4c3cb222a6b7ea02
4
+ data.tar.gz: 85e5c5168e6002be4cc8f486918d101bd7561eb1
5
+ SHA512:
6
+ metadata.gz: 83d79a0250ade8e2fb51c72b449b214a19219edacdcfe55fa7b8c56d2ccee4beda374acebd4ce57ab424eb6af40e0809b6d9068456fe4bac80687d5ffcffe080
7
+ data.tar.gz: e739c358d8a5fcf378cbb7191ee01965a64415a8792981b25aab3898f8632e8411f9a416f3af76883f059edda2d4ef65d3dd083825b3e49bddeb421233e2f692
data/.gitignore CHANGED
@@ -3,7 +3,6 @@
3
3
  .bundle
4
4
  .config
5
5
  .yardoc
6
- Gemfile.lock
7
6
  InstalledFiles
8
7
  _yardoc
9
8
  coverage
data/Gemfile.lock ADDED
@@ -0,0 +1,69 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ tracker-git (0.0.4)
5
+ pivotal-tracker (>= 0.5.10)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ builder (3.1.4)
11
+ coderay (1.0.8)
12
+ crack (0.3.1)
13
+ diff-lcs (1.1.3)
14
+ guard (1.5.4)
15
+ listen (>= 0.4.2)
16
+ lumberjack (>= 1.0.2)
17
+ pry (>= 0.9.10)
18
+ thor (>= 0.14.6)
19
+ guard-rspec (2.3.1)
20
+ guard (>= 1.1)
21
+ rspec (~> 2.11)
22
+ happymapper (0.4.0)
23
+ libxml-ruby (~> 2.0)
24
+ libxml-ruby (2.4.0)
25
+ listen (0.6.0)
26
+ lumberjack (1.0.2)
27
+ method_source (0.8.1)
28
+ mime-types (1.19)
29
+ nokogiri (1.5.5)
30
+ nokogiri-happymapper (0.5.6)
31
+ nokogiri (~> 1.5)
32
+ pivotal-tracker (0.5.10)
33
+ builder
34
+ crack
35
+ happymapper (>= 0.3.2)
36
+ nokogiri (>= 1.4.3)
37
+ nokogiri (>= 1.5.5)
38
+ nokogiri-happymapper (>= 0.5.4)
39
+ rest-client (~> 1.6.0)
40
+ pry (0.9.10)
41
+ coderay (~> 1.0.5)
42
+ method_source (~> 0.8)
43
+ slop (~> 3.3.1)
44
+ rake (10.0.3)
45
+ rest-client (1.6.7)
46
+ mime-types (>= 1.16)
47
+ rspec (2.12.0)
48
+ rspec-core (~> 2.12.0)
49
+ rspec-expectations (~> 2.12.0)
50
+ rspec-mocks (~> 2.12.0)
51
+ rspec-core (2.12.2)
52
+ rspec-expectations (2.12.0)
53
+ diff-lcs (~> 1.1.3)
54
+ rspec-mocks (2.12.0)
55
+ slop (3.3.3)
56
+ thor (0.16.0)
57
+
58
+ PLATFORMS
59
+ ruby
60
+
61
+ DEPENDENCIES
62
+ guard-rspec
63
+ happymapper
64
+ nokogiri
65
+ pivotal-tracker (>= 0.5.10)
66
+ rake
67
+ rest-client
68
+ rspec
69
+ tracker-git!
data/README.md CHANGED
@@ -10,6 +10,7 @@ This has proved useful as part of a 'deploy to staging' strategy. If you automat
10
10
 
11
11
  [![Build Status](https://secure.travis-ci.org/robb1e/tracker-git.png)](http://travis-ci.org/robb1e/tracker-git)
12
12
  [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/robb1e/tracker-git)
13
+ [![Dependency Status](https://gemnasium.com/robb1e/tracker-git.png)](https://gemnasium.com/robb1e/tracker-git)
13
14
 
14
15
  ## Installation
15
16
 
@@ -34,6 +35,11 @@ delivered.
34
35
 
35
36
  export TRACKER_PROJECT_ID=123456
36
37
  export TRACKER_TOKEN=abc123
38
+ tracker
39
+
40
+ You can also pass the project id and token in as parameters
41
+
42
+ tracker 123456 abc123
37
43
 
38
44
  Optionally you can specify a git branch to search for completed story IDs as
39
45
  the third command line argument or with the GIT\_BRANCH environment variable.
data/bin/tracker CHANGED
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
+ require 'optparse'
3
+
2
4
  begin
3
5
  require 'tracker-git'
4
6
  rescue LoadError
@@ -6,6 +8,15 @@ rescue LoadError
6
8
  require 'tracker-git'
7
9
  end
8
10
 
11
+ options = {}
12
+ OptionParser.new do |opts|
13
+ opts.banner = "Usage: example.rb [options]"
14
+
15
+ opts.on("-l", "--label LABEL", "Add a label to a story marked as deployed") do |label|
16
+ options[:label] = label if label =~ /[^[:space:]]/
17
+ end
18
+ end.parse!
19
+
9
20
  project_id, tracker_token, git_branch = \
10
21
  if [2, 3].include? ARGV.size
11
22
  ARGV
@@ -29,4 +40,4 @@ end
29
40
  project = Tracker::Project.new(tracker_token, project_id)
30
41
  git = Tracker::Git.new
31
42
  deliverer = Tracker::Deliverer.new(project, git)
32
- deliverer.mark_as_delivered(git_branch)
43
+ deliverer.mark_as_delivered(git_branch, options[:label])
@@ -6,13 +6,14 @@ module Tracker
6
6
  @git = git
7
7
  end
8
8
 
9
- def mark_as_delivered(branch = nil)
9
+ def mark_as_delivered(branch = nil, label = nil)
10
10
  options = {}
11
11
  options[:branch] = branch if branch
12
12
 
13
13
  project.finished.each do |story|
14
14
  if git.contains?(story.id, options)
15
15
  project.deliver(story)
16
+ project.add_label(story, label) if label
16
17
  end
17
18
  end
18
19
  end
@@ -21,6 +21,12 @@ module Tracker
21
21
  story.update(current_state: "delivered")
22
22
  end
23
23
 
24
+ def add_label(story, label)
25
+ labels = (story.labels || "").split(",")
26
+ labels << label
27
+ story.update(labels: labels.join(","))
28
+ end
29
+
24
30
  private
25
31
  def _project
26
32
  @project ||= PivotalTracker::Project.find(project_id)
@@ -1,3 +1,3 @@
1
1
  module Tracker
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -35,6 +35,20 @@ describe Tracker::Deliverer do
35
35
  deliverer.mark_as_delivered('develop')
36
36
  end
37
37
  end
38
+
39
+ context 'when given a label to add' do
40
+ it('should mark stories as delivered and add a label') do
41
+ project.should_receive(:finished) { finished_stories }
42
+ git.should_receive(:contains?).with(1, {}) { true }
43
+ git.should_receive(:contains?).with(2, {}) { false }
44
+ project.should_receive(:deliver).with(commited_story)
45
+ project.should_not_receive(:deliver).with(uncommited_story)
46
+ project.should_receive(:add_label).with(commited_story, 'label')
47
+ project.should_not_receive(:add_label).with(uncommited_story, 'label')
48
+
49
+ deliverer.mark_as_delivered(nil, 'label')
50
+ end
51
+ end
38
52
  end
39
53
 
40
54
  end
data/spec/project_spec.rb CHANGED
@@ -43,4 +43,33 @@ describe Tracker::Project do
43
43
  end
44
44
  end
45
45
 
46
+ describe "#add_label" do
47
+ let(:project) { Tracker::Project.new(stub, stub) }
48
+ let(:story) { stub }
49
+
50
+ context 'there is no label on the story' do
51
+ it "adds a label" do
52
+ story.should_receive(:labels) { '' }
53
+ story.should_receive(:update).with(labels: 'label')
54
+ project.add_label(story, 'label')
55
+ end
56
+ end
57
+
58
+ context 'there is already one label on the story' do
59
+ it "adds a label" do
60
+ story.should_receive(:labels) { 'foo' }
61
+ story.should_receive(:update).with(labels: 'foo,label')
62
+ project.add_label(story, 'label')
63
+ end
64
+ end
65
+
66
+ context 'there is already two labels on the story' do
67
+ it "adds a label" do
68
+ story.should_receive(:labels) { 'foo,bar' }
69
+ story.should_receive(:update).with(labels: 'foo,bar,label')
70
+ project.add_label(story, 'label')
71
+ end
72
+ end
73
+ end
74
+
46
75
  end
data/tracker-git.gemspec CHANGED
@@ -7,6 +7,7 @@ Gem::Specification.new do |gem|
7
7
  gem.description = %q{Tracker integration: Update Tracker based on current Git repo.}
8
8
  gem.summary = %q{Tracker integration.}
9
9
  gem.homepage = ""
10
+ gem.license = 'MIT'
10
11
 
11
12
  gem.add_runtime_dependency('pivotal-tracker', '>= 0.5.10')
12
13
  gem.add_development_dependency "rspec"
metadata CHANGED
@@ -1,81 +1,72 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tracker-git
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
5
- prerelease:
4
+ version: 0.0.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Robbie Clutton
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-11-26 00:00:00.000000000 Z
11
+ date: 2014-06-20 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: pivotal-tracker
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: 0.5.10
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: 0.5.10
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rspec
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: guard-rspec
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rake
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ">="
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - ">="
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
- description: ! 'Tracker integration: Update Tracker based on current Git repo.'
69
+ description: 'Tracker integration: Update Tracker based on current Git repo.'
79
70
  email:
80
71
  - robert.clutton@gmail.com
81
72
  executables:
@@ -83,10 +74,11 @@ executables:
83
74
  extensions: []
84
75
  extra_rdoc_files: []
85
76
  files:
86
- - .gitignore
87
- - .rspec
88
- - .travis.yml
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".travis.yml"
89
80
  - Gemfile
81
+ - Gemfile.lock
90
82
  - Guardfile
91
83
  - LICENSE
92
84
  - README.md
@@ -103,34 +95,28 @@ files:
103
95
  - spec/spec_helper.rb
104
96
  - tracker-git.gemspec
105
97
  homepage: ''
106
- licenses: []
98
+ licenses:
99
+ - MIT
100
+ metadata: {}
107
101
  post_install_message:
108
102
  rdoc_options: []
109
103
  require_paths:
110
104
  - lib
111
105
  required_ruby_version: !ruby/object:Gem::Requirement
112
- none: false
113
106
  requirements:
114
- - - ! '>='
107
+ - - ">="
115
108
  - !ruby/object:Gem::Version
116
109
  version: '0'
117
- segments:
118
- - 0
119
- hash: -4280214816853618428
120
110
  required_rubygems_version: !ruby/object:Gem::Requirement
121
- none: false
122
111
  requirements:
123
- - - ! '>='
112
+ - - ">="
124
113
  - !ruby/object:Gem::Version
125
114
  version: '0'
126
- segments:
127
- - 0
128
- hash: -4280214816853618428
129
115
  requirements: []
130
116
  rubyforge_project:
131
- rubygems_version: 1.8.24
117
+ rubygems_version: 2.2.2
132
118
  signing_key:
133
- specification_version: 3
119
+ specification_version: 4
134
120
  summary: Tracker integration.
135
121
  test_files:
136
122
  - spec/deliverer_spec.rb