git-storyid 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.2.0
data/git-storyid.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "git-storyid"
8
- s.version = "0.1.2"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Bogdan Gusiev"]
12
- s.date = "2012-09-04"
12
+ s.date = "2013-02-09"
13
13
  s.description = "Helps include pivotal story id and description in commit"
14
14
  s.email = "agresso@gmail.com"
15
15
  s.executables = ["git-storyid"]
@@ -36,7 +36,7 @@ Gem::Specification.new do |s|
36
36
  s.homepage = "http://github.com/bogdan/git-storyid"
37
37
  s.licenses = ["MIT"]
38
38
  s.require_paths = ["lib"]
39
- s.rubygems_version = "1.8.11"
39
+ s.rubygems_version = "1.8.24"
40
40
  s.summary = "Attach commits to pivotal stories"
41
41
 
42
42
  if s.respond_to? :specification_version then
data/lib/git_storyid.rb CHANGED
@@ -2,6 +2,7 @@ require "readline"
2
2
  require "optparse"
3
3
  require "pivotal_tracker"
4
4
  require "yaml"
5
+ require "open3"
5
6
 
6
7
  class GitStoryid
7
8
 
@@ -34,7 +35,7 @@ class GitStoryid
34
35
  end
35
36
 
36
37
  def run
37
- if `git diff --staged`.empty?
38
+ if execute("git", "diff", "--staged").empty?
38
39
  puts "No changes staged to commit."
39
40
  exit 1
40
41
  end
@@ -61,7 +62,11 @@ class GitStoryid
61
62
  message += @message.to_s + "\n\n"
62
63
  end
63
64
  message += @stories.map {|s| "Feature: " + s.name.strip}.join("\n\n")
64
- puts `git commit -m "#{message}"`
65
+ puts execute("git", "commit", "-m", message)
66
+ end
67
+
68
+ def execute(*args)
69
+ Open3.popen3(*args) {|i, o| return o.read }
65
70
  end
66
71
 
67
72
 
@@ -70,13 +75,21 @@ class GitStoryid
70
75
  class << self
71
76
  def read
72
77
  return if @loaded
78
+ load_config
79
+ ensure_full_config
80
+ setup_api_client
81
+ @loaded = true
82
+ end
83
+
84
+ def load_config
73
85
  @config = load_config_from(global_config_path)
74
86
  @project_config = load_config_from(project_config_path)
75
87
  @config.merge!(@project_config)
76
- ensure_full_config
88
+ end
89
+
90
+ def setup_api_client
77
91
  PivotalTracker::Client.token = @config['api_token']
78
92
  PivotalTracker::Client.use_ssl = @config['use_ssl'] ? @config['use_ssl'] : false
79
- @loaded = true
80
93
  end
81
94
 
82
95
  def ensure_full_config
@@ -90,14 +103,7 @@ class GitStoryid
90
103
  if @config[key].nil?
91
104
  changed = true
92
105
  value = Readline.readline("#{label}: ", true)
93
- @project_config[key] = case value
94
- when "y"
95
- true
96
- when "n"
97
- false
98
- else
99
- value
100
- end
106
+ @project_config[key] = format_config_value(value)
101
107
  end
102
108
  end
103
109
  if changed
@@ -109,6 +115,17 @@ class GitStoryid
109
115
  end
110
116
  end
111
117
 
118
+ def format_config_value(value)
119
+ case value
120
+ when "y"
121
+ true
122
+ when "n"
123
+ false
124
+ else
125
+ value
126
+ end
127
+ end
128
+
112
129
  def load_config_from(path)
113
130
  return {} unless path
114
131
  file = File.join path,'.pivotalrc'
@@ -1,7 +1,14 @@
1
1
  require "spec_helper"
2
+ require "fileutils"
2
3
 
3
4
  describe GitStoryid do
4
- it "fails" do
5
- fail "hey buddy, you should probably rename this file and start specing for real"
5
+
6
+ before(:each) do
7
+ FileUtils.rm_rf("spec/repo")
8
+ FileUtils.mkdir_p("spec/repo")
9
+ FileUtils.cd("spec/repo")
10
+ `git init`
6
11
  end
12
+
13
+
7
14
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-storyid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-04 00:00:00.000000000 Z
12
+ date: 2013-02-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pivotal-tracker
16
- requirement: &8514840 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *8514840
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rspec
27
- requirement: &8512340 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ~>
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: 2.8.0
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *8512340
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 2.8.0
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: jeweler
38
- requirement: &8524860 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ~>
@@ -43,7 +53,12 @@ dependencies:
43
53
  version: 1.8.3
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *8524860
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.8.3
47
62
  description: Helps include pivotal story id and description in commit
48
63
  email: agresso@gmail.com
49
64
  executables:
@@ -82,7 +97,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
82
97
  version: '0'
83
98
  segments:
84
99
  - 0
85
- hash: 956355888598505054
100
+ hash: -1277588774395316013
86
101
  required_rubygems_version: !ruby/object:Gem::Requirement
87
102
  none: false
88
103
  requirements:
@@ -91,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
106
  version: '0'
92
107
  requirements: []
93
108
  rubyforge_project:
94
- rubygems_version: 1.8.11
109
+ rubygems_version: 1.8.24
95
110
  signing_key:
96
111
  specification_version: 3
97
112
  summary: Attach commits to pivotal stories