git-storyid 0.1.0
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/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +47 -0
- data/LICENSE.txt +20 -0
- data/README.md +16 -0
- data/Rakefile +41 -0
- data/VERSION +1 -0
- data/bin/git-storyid +11 -0
- data/git-storyid.gemspec +60 -0
- data/lib/git-storyid.rb +1 -0
- data/lib/git_storyid.rb +157 -0
- data/spec/git_storyid_spec.rb +7 -0
- data/spec/spec_helper.rb +12 -0
- metadata +98 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
builder (3.0.0)
|
5
|
+
diff-lcs (1.1.3)
|
6
|
+
git (1.2.5)
|
7
|
+
happymapper (0.4.0)
|
8
|
+
libxml-ruby (~> 2.0)
|
9
|
+
jeweler (1.8.4)
|
10
|
+
bundler (~> 1.0)
|
11
|
+
git (>= 1.2.5)
|
12
|
+
rake
|
13
|
+
rdoc
|
14
|
+
json (1.7.3)
|
15
|
+
libxml-ruby (2.3.3)
|
16
|
+
mime-types (1.19)
|
17
|
+
nokogiri (1.5.5)
|
18
|
+
pivotal-tracker (0.5.4)
|
19
|
+
builder
|
20
|
+
builder
|
21
|
+
happymapper (>= 0.3.2)
|
22
|
+
happymapper (>= 0.3.2)
|
23
|
+
nokogiri (>= 1.4.3)
|
24
|
+
nokogiri (~> 1.4)
|
25
|
+
rest-client (~> 1.6.0)
|
26
|
+
rest-client (~> 1.6.0)
|
27
|
+
rake (0.9.2.2)
|
28
|
+
rdoc (3.12)
|
29
|
+
json (~> 1.4)
|
30
|
+
rest-client (1.6.7)
|
31
|
+
mime-types (>= 1.16)
|
32
|
+
rspec (2.8.0)
|
33
|
+
rspec-core (~> 2.8.0)
|
34
|
+
rspec-expectations (~> 2.8.0)
|
35
|
+
rspec-mocks (~> 2.8.0)
|
36
|
+
rspec-core (2.8.0)
|
37
|
+
rspec-expectations (2.8.0)
|
38
|
+
diff-lcs (~> 1.1.2)
|
39
|
+
rspec-mocks (2.8.0)
|
40
|
+
|
41
|
+
PLATFORMS
|
42
|
+
ruby
|
43
|
+
|
44
|
+
DEPENDENCIES
|
45
|
+
jeweler (~> 1.8.3)
|
46
|
+
pivotal-tracker
|
47
|
+
rspec (~> 2.8.0)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Bogdan Gusiev
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "git-storyid"
|
18
|
+
gem.executables = ['git-storyid']
|
19
|
+
gem.homepage = "http://github.com/bogdan/git-storyid"
|
20
|
+
gem.license = "MIT"
|
21
|
+
gem.summary = %Q{Attach commits to pivotal stories}
|
22
|
+
gem.description = %Q{Helps include pivotal story id and description in commit}
|
23
|
+
gem.email = "agresso@gmail.com"
|
24
|
+
gem.authors = ["Bogdan Gusiev"]
|
25
|
+
# dependencies defined in Gemfile
|
26
|
+
end
|
27
|
+
Jeweler::RubygemsDotOrgTasks.new
|
28
|
+
|
29
|
+
require 'rspec/core'
|
30
|
+
require 'rspec/core/rake_task'
|
31
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
32
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
33
|
+
end
|
34
|
+
|
35
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
36
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
37
|
+
spec.rcov = true
|
38
|
+
end
|
39
|
+
|
40
|
+
task :default => :spec
|
41
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/bin/git-storyid
ADDED
data/git-storyid.gemspec
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "git-storyid"
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Bogdan Gusiev"]
|
12
|
+
s.date = "2012-09-03"
|
13
|
+
s.description = "Helps include pivotal story id and description in commit"
|
14
|
+
s.email = "agresso@gmail.com"
|
15
|
+
s.executables = ["git-storyid"]
|
16
|
+
s.extra_rdoc_files = [
|
17
|
+
"LICENSE.txt",
|
18
|
+
"README.md"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
".document",
|
22
|
+
".rspec",
|
23
|
+
"Gemfile",
|
24
|
+
"Gemfile.lock",
|
25
|
+
"LICENSE.txt",
|
26
|
+
"README.md",
|
27
|
+
"Rakefile",
|
28
|
+
"VERSION",
|
29
|
+
"bin/git-storyid",
|
30
|
+
"git-storyid.gemspec",
|
31
|
+
"lib/git-storyid.rb",
|
32
|
+
"lib/git_storyid.rb",
|
33
|
+
"spec/git_storyid_spec.rb",
|
34
|
+
"spec/spec_helper.rb"
|
35
|
+
]
|
36
|
+
s.homepage = "http://github.com/bogdan/git-storyid"
|
37
|
+
s.licenses = ["MIT"]
|
38
|
+
s.require_paths = ["lib"]
|
39
|
+
s.rubygems_version = "1.8.11"
|
40
|
+
s.summary = "Attach commits to pivotal stories"
|
41
|
+
|
42
|
+
if s.respond_to? :specification_version then
|
43
|
+
s.specification_version = 3
|
44
|
+
|
45
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
46
|
+
s.add_runtime_dependency(%q<pivotal-tracker>, [">= 0"])
|
47
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
|
48
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
|
49
|
+
else
|
50
|
+
s.add_dependency(%q<pivotal-tracker>, [">= 0"])
|
51
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
52
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
53
|
+
end
|
54
|
+
else
|
55
|
+
s.add_dependency(%q<pivotal-tracker>, [">= 0"])
|
56
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
57
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
data/lib/git-storyid.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "git_storyid"
|
data/lib/git_storyid.rb
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
require "readline"
|
2
|
+
require "optparse"
|
3
|
+
require "pivotal_tracker"
|
4
|
+
require "yaml"
|
5
|
+
|
6
|
+
class GitStoryid
|
7
|
+
|
8
|
+
def self.run(*args)
|
9
|
+
new(*args).run
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(*arguments)
|
13
|
+
parser = OptionParser.new do |opts|
|
14
|
+
opts.banner = "Do git commit with information from pivotal story"
|
15
|
+
opts.on("-m [MESSAGE]", "Add addional MESSAGE to comit") do |message|
|
16
|
+
@message = message
|
17
|
+
end
|
18
|
+
end
|
19
|
+
parser.parse!
|
20
|
+
|
21
|
+
unless arguments.empty?
|
22
|
+
@stories = arguments.map do |argument|
|
23
|
+
Configuration.project.stories.find(argument)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def all_stories
|
29
|
+
@all_stories ||= Configuration.project.stories.all(
|
30
|
+
:owner => Configuration.me,
|
31
|
+
:state => %w(started finished delivered),
|
32
|
+
:limit => 30
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
def run
|
37
|
+
if `git diff --staged`.empty?
|
38
|
+
puts "No changes staged to commit."
|
39
|
+
exit 1
|
40
|
+
end
|
41
|
+
|
42
|
+
unless @stories
|
43
|
+
unless all_stories.empty?
|
44
|
+
all_stories.each_with_index do |story, index|
|
45
|
+
puts "[#{index + 1}] #{story.name}"
|
46
|
+
end
|
47
|
+
puts ""
|
48
|
+
@stories = Readline.readline("Indexes(csv): ", true).split(/\s*,\s*/).reject do |string|
|
49
|
+
string == ""
|
50
|
+
end.map do |string|
|
51
|
+
index = string.to_i
|
52
|
+
all_stories[index - 1] || (return puts("Story index #{index} not found."))
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
57
|
+
message = ("[#{@stories.map { |s| "\##{s.id}"}.join(", ")}]").rjust 12
|
58
|
+
message += ' '
|
59
|
+
if @message && !@message.empty?
|
60
|
+
message += @message.to_s + "\n\n"
|
61
|
+
end
|
62
|
+
message += @stories.map {|s| "Feature: " + s.name.strip}.join("\n\n")
|
63
|
+
puts `git commit -m "#{message}"`
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
module Configuration
|
69
|
+
class << self
|
70
|
+
def read
|
71
|
+
return if @loaded
|
72
|
+
@config = load_config_from(global_config_path)
|
73
|
+
@project_config = load_config_from(project_config_path)
|
74
|
+
@config.merge!(@project_config)
|
75
|
+
ensure_full_config
|
76
|
+
PivotalTracker::Client.token = @config['api_token']
|
77
|
+
PivotalTracker::Client.use_ssl = @config['use_ssl'] ? @config['use_ssl'] : false
|
78
|
+
@loaded = true
|
79
|
+
end
|
80
|
+
|
81
|
+
def ensure_full_config
|
82
|
+
changed = false
|
83
|
+
{
|
84
|
+
"api_token" => "Api token (https://www.pivotaltracker.com/profile)",
|
85
|
+
"use_ssl" => "Use SSL (y/n)",
|
86
|
+
"me" => "Your pivotal initials (e.g. BG)",
|
87
|
+
"project_id" => "Project ID"
|
88
|
+
}.each do |key, label|
|
89
|
+
unless @config[key]
|
90
|
+
changed = true
|
91
|
+
value = Readline.readline("#{label}: ", true)
|
92
|
+
@project_config[key] = case value
|
93
|
+
when "y"
|
94
|
+
true
|
95
|
+
when "n"
|
96
|
+
false
|
97
|
+
else
|
98
|
+
value
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
if changed
|
103
|
+
File.open("./.pivotalrc", "w") do |file|
|
104
|
+
file.write YAML.dump(@project_config)
|
105
|
+
end
|
106
|
+
@config.merge!(@project_config)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def load_config_from(path)
|
111
|
+
return {} unless path
|
112
|
+
file = File.join path,'.pivotalrc'
|
113
|
+
if File.exists?(file)
|
114
|
+
YAML.load(File.read(file)) || {}
|
115
|
+
else
|
116
|
+
{}
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def project
|
121
|
+
read
|
122
|
+
@project ||= PivotalTracker::Project.find(@config['project_id'])
|
123
|
+
end
|
124
|
+
|
125
|
+
def me
|
126
|
+
read
|
127
|
+
@me ||= @config['me']
|
128
|
+
end
|
129
|
+
|
130
|
+
def global_config_path
|
131
|
+
@global_config_path ||= File.expand_path('~')
|
132
|
+
end
|
133
|
+
|
134
|
+
def project_config_path
|
135
|
+
@project_config_path ||= find_project_config
|
136
|
+
end
|
137
|
+
|
138
|
+
|
139
|
+
private
|
140
|
+
|
141
|
+
def find_project_config
|
142
|
+
dirs = File.split(Dir.pwd)
|
143
|
+
until dirs.empty? || File.exists?(File.join(dirs, '.pivotalrc'))
|
144
|
+
dirs.pop
|
145
|
+
end
|
146
|
+
if dirs.empty? || File.join(dirs, '.pivotalrc')==global_config_path
|
147
|
+
nil
|
148
|
+
else
|
149
|
+
File.join(dirs)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
class Error < StandardError
|
156
|
+
end
|
157
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'git-storyid'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: git-storyid
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Bogdan Gusiev
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-09-03 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: pivotal-tracker
|
16
|
+
requirement: &18360300 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *18360300
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
requirement: &18391140 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.8.0
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *18391140
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: jeweler
|
38
|
+
requirement: &18399340 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.8.3
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *18399340
|
47
|
+
description: Helps include pivotal story id and description in commit
|
48
|
+
email: agresso@gmail.com
|
49
|
+
executables:
|
50
|
+
- git-storyid
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files:
|
53
|
+
- LICENSE.txt
|
54
|
+
- README.md
|
55
|
+
files:
|
56
|
+
- .document
|
57
|
+
- .rspec
|
58
|
+
- Gemfile
|
59
|
+
- Gemfile.lock
|
60
|
+
- LICENSE.txt
|
61
|
+
- README.md
|
62
|
+
- Rakefile
|
63
|
+
- VERSION
|
64
|
+
- bin/git-storyid
|
65
|
+
- git-storyid.gemspec
|
66
|
+
- lib/git-storyid.rb
|
67
|
+
- lib/git_storyid.rb
|
68
|
+
- spec/git_storyid_spec.rb
|
69
|
+
- spec/spec_helper.rb
|
70
|
+
homepage: http://github.com/bogdan/git-storyid
|
71
|
+
licenses:
|
72
|
+
- MIT
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
segments:
|
84
|
+
- 0
|
85
|
+
hash: 2052410436570425512
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
88
|
+
requirements:
|
89
|
+
- - ! '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 1.8.11
|
95
|
+
signing_key:
|
96
|
+
specification_version: 3
|
97
|
+
summary: Attach commits to pivotal stories
|
98
|
+
test_files: []
|