gitmine 0.1.4.pre.1 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/gitmine.gemspec +3 -3
- data/lib/gitmine/cli.rb +28 -4
- data/lib/gitmine/gitmine.rb +52 -1
- data/lib/gitmine/issue.rb +7 -3
- data/spec/issue_spec.rb +2 -1
- metadata +9 -13
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.5
|
data/gitmine.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{gitmine}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.5"
|
9
9
|
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new("
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Philippe Creux"]
|
12
|
-
s.date = %q{2010-11-
|
12
|
+
s.date = %q{2010-11-24}
|
13
13
|
s.default_executable = %q{gitmine}
|
14
14
|
s.description = %q{Git log with status of associated redmine tickets}
|
15
15
|
s.email = %q{pcreux@gmail.com}
|
data/lib/gitmine/cli.rb
CHANGED
@@ -2,15 +2,31 @@ module Gitmine
|
|
2
2
|
class CLI
|
3
3
|
def self.run
|
4
4
|
case ARGV[0]
|
5
|
-
when
|
5
|
+
when "log"
|
6
6
|
list
|
7
|
-
when "branch"
|
7
|
+
when "branch", "br"
|
8
8
|
branch
|
9
|
+
when "checkout", "co"
|
10
|
+
checkout
|
11
|
+
when "delete", "del"
|
12
|
+
delete
|
9
13
|
else
|
10
14
|
puts <<-EOS
|
11
15
|
Usage:
|
12
|
-
gitmine
|
13
|
-
|
16
|
+
gitmine branch BRANCH_NAME
|
17
|
+
Create a new branch, push to origin, add github links to gitmine ticket
|
18
|
+
Example: gitmine branch 1234-my-branch
|
19
|
+
|
20
|
+
gitmine checkout ISSUE_ID
|
21
|
+
Checkout remote/local branch starting with ISSUE_ID
|
22
|
+
Example: gitmine checkout 1234
|
23
|
+
|
24
|
+
gitmine delete ISSUE_ID
|
25
|
+
Delete remote branch starting with ISSUE_ID
|
26
|
+
Example: gitmine delete 1234
|
27
|
+
|
28
|
+
gitmine log
|
29
|
+
Displays latest 10 commits and the status of their associated Redmine tickets
|
14
30
|
EOS
|
15
31
|
end
|
16
32
|
end
|
@@ -22,5 +38,13 @@ module Gitmine
|
|
22
38
|
def self.branch
|
23
39
|
Gitmine.branch(ARGV[1])
|
24
40
|
end
|
41
|
+
|
42
|
+
def self.checkout
|
43
|
+
Gitmine.checkout(ARGV[1])
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.delete
|
47
|
+
Gitmine.delete(ARGV[1])
|
48
|
+
end
|
25
49
|
end
|
26
50
|
end
|
data/lib/gitmine/gitmine.rb
CHANGED
@@ -20,6 +20,7 @@ module Gitmine
|
|
20
20
|
end
|
21
21
|
|
22
22
|
|
23
|
+
# TODO specs
|
23
24
|
def self.branch(branch_name)
|
24
25
|
issue_id = branch_name[/^\d+/]
|
25
26
|
original_branch = File.read('./.git/HEAD').match(/^ref: refs\/heads\/(.+)/)[1]
|
@@ -43,12 +44,62 @@ module Gitmine
|
|
43
44
|
note << %{ - "Compare on Github":https://github.com/#{config['github']}/compare/#{original_branch}...#{branch_name}}
|
44
45
|
end
|
45
46
|
|
46
|
-
Issue.find(issue_id).add_note(note)
|
47
|
+
puts 'Done!' if Issue.find(issue_id).add_note(note)
|
48
|
+
end
|
49
|
+
|
50
|
+
# TODO specs
|
51
|
+
def self.checkout(issue_id)
|
52
|
+
if local_branch = local_branches.select { |branch| branch[/^#{issue_id}-/] }.first
|
53
|
+
run_cmd("git checkout #{local_branch}")
|
54
|
+
return
|
55
|
+
end
|
56
|
+
|
57
|
+
if remote_branch = remote_branches.select { |branch| branch[/^#{issue_id}-/] }.first
|
58
|
+
run_cmd("git checkout -b #{remote_branch} origin/#{remote_branch}")
|
59
|
+
return
|
60
|
+
end
|
61
|
+
|
62
|
+
raise "Can't find branch starting with #{issue_id}"
|
63
|
+
end
|
64
|
+
|
65
|
+
# TODO specs
|
66
|
+
def self.delete(issue_id)
|
67
|
+
if remote_branch = remote_branches.select { |branch| branch[/^#{issue_id}-/] }.first
|
68
|
+
run_cmd("git push origin :#{remote_branch}")
|
69
|
+
else
|
70
|
+
raise "Can't find branch starting with #{issue_id}"
|
71
|
+
end
|
47
72
|
end
|
48
73
|
|
49
74
|
def self.run_cmd(cmd)
|
50
75
|
puts cmd
|
51
76
|
exit! unless system(cmd)
|
52
77
|
end
|
78
|
+
|
79
|
+
# TODO specs
|
80
|
+
def self.local_branches
|
81
|
+
branches = []
|
82
|
+
`git branch`.each_line do |line|
|
83
|
+
if match = line[/\d+.*$/]
|
84
|
+
branches << match
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
branches
|
89
|
+
end
|
90
|
+
|
91
|
+
# TODO specs
|
92
|
+
def self.remote_branches
|
93
|
+
run_cmd("git fetch")
|
94
|
+
|
95
|
+
branches = []
|
96
|
+
`git branch -r`.each_line do |line|
|
97
|
+
if match = line.match(/origin\/(\d+.*)/)
|
98
|
+
branches << match[1]
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
branches
|
103
|
+
end
|
53
104
|
end
|
54
105
|
end
|
data/lib/gitmine/issue.rb
CHANGED
@@ -44,9 +44,13 @@ module Gitmine
|
|
44
44
|
|
45
45
|
# Add a note to the Issue
|
46
46
|
def add_note(note)
|
47
|
-
|
48
|
-
|
49
|
-
|
47
|
+
response = self.class.put(url(self.id), :query => {:notes => note}, :body => "") # nginx reject requests without body
|
48
|
+
|
49
|
+
if response.code == 200
|
50
|
+
return true
|
51
|
+
else
|
52
|
+
raise response.response
|
53
|
+
end
|
50
54
|
end
|
51
55
|
|
52
56
|
include HTTParty
|
data/spec/issue_spec.rb
CHANGED
@@ -51,9 +51,10 @@ describe Gitmine::Issue do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
describe "#add_note" do
|
54
|
+
let(:httparty_response) { mock(:http_party_response, :code => 200) }
|
54
55
|
it "should PUT a note" do
|
55
56
|
issue.stub!(:id) { 1 }
|
56
|
-
issue.class.should_receive(:put).with('/1.xml', :query => {:notes => "Hello"}, :body => "")
|
57
|
+
issue.class.should_receive(:put).with('/1.xml', :query => {:notes => "Hello"}, :body => "") { httparty_response }
|
57
58
|
issue.add_note("Hello")
|
58
59
|
end
|
59
60
|
end
|
metadata
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitmine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 17
|
5
|
+
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
|
11
|
-
- 1
|
12
|
-
version: 0.1.4.pre.1
|
9
|
+
- 5
|
10
|
+
version: 0.1.5
|
13
11
|
platform: ruby
|
14
12
|
authors:
|
15
13
|
- Philippe Creux
|
@@ -17,7 +15,7 @@ autorequire:
|
|
17
15
|
bindir: bin
|
18
16
|
cert_chain: []
|
19
17
|
|
20
|
-
date: 2010-11-
|
18
|
+
date: 2010-11-24 00:00:00 -08:00
|
21
19
|
default_executable: gitmine
|
22
20
|
dependencies:
|
23
21
|
- !ruby/object:Gem::Dependency
|
@@ -118,14 +116,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
118
116
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
117
|
none: false
|
120
118
|
requirements:
|
121
|
-
- - "
|
119
|
+
- - ">="
|
122
120
|
- !ruby/object:Gem::Version
|
123
|
-
hash:
|
121
|
+
hash: 3
|
124
122
|
segments:
|
125
|
-
-
|
126
|
-
|
127
|
-
- 1
|
128
|
-
version: 1.3.1
|
123
|
+
- 0
|
124
|
+
version: "0"
|
129
125
|
requirements: []
|
130
126
|
|
131
127
|
rubyforge_project:
|