git-topic 0.1.6.3 → 0.1.6.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/.autotest +10 -0
  2. data/.vimrc +21 -1
  3. data/Gemfile +2 -0
  4. data/Gemfile.lock +2 -0
  5. data/Rakefile +4 -11
  6. data/VERSION.yml +1 -1
  7. data/bin/git-topic +1 -165
  8. data/git-topic +13 -0
  9. data/git-topic.gemspec +52 -6
  10. data/lib/git_topic/cli.rb +171 -0
  11. data/lib/git_topic/git.rb +13 -3
  12. data/lib/git_topic/naming.rb +16 -8
  13. data/lib/git_topic.rb +15 -9
  14. data/lib/tasks/annotations.rake +20 -0
  15. data/spec/git_topic_spec.rb +107 -6
  16. data/spec/template/origin/ORIG_HEAD +1 -0
  17. data/spec/template/origin/RENAMED-REF +1 -0
  18. data/spec/template/origin/objects/2d/a16986c7f742f808a3a3e68108bd2e4dae009d +0 -0
  19. data/spec/template/origin/objects/65/3d7112dadcacaaae6390612eac58c234f92b18 +2 -0
  20. data/spec/template/origin/objects/dd/26afde91bbae18e13e4df1cd1da56a75ccc665 +0 -0
  21. data/spec/template/origin/refs/heads/rejected/{davidjh → USER}/krakens +0 -0
  22. data/spec/template/origin/refs/heads/review/{davidjh → USER}/pirates +0 -0
  23. data/spec/template/origin/refs/heads/wip/USER/pirates-advanced +1 -0
  24. data/spec/template/origin/refs/heads/wip/USER/zombie-basic +1 -0
  25. data/spec/template/origin/refs/heads/wip/prevent-ff +1 -0
  26. data/spec/template/origin-fresh/HEAD +1 -0
  27. data/spec/template/origin-fresh/RENAMED-REF +1 -0
  28. data/spec/template/origin-fresh/config +7 -0
  29. data/spec/template/origin-fresh/description +1 -0
  30. data/spec/template/origin-fresh/hooks/applypatch-msg.sample +15 -0
  31. data/spec/template/origin-fresh/hooks/commit-msg.sample +24 -0
  32. data/spec/template/origin-fresh/hooks/post-commit.sample +8 -0
  33. data/spec/template/origin-fresh/hooks/post-receive.sample +15 -0
  34. data/spec/template/origin-fresh/hooks/post-update.sample +8 -0
  35. data/spec/template/origin-fresh/hooks/pre-applypatch.sample +14 -0
  36. data/spec/template/origin-fresh/hooks/pre-commit.sample +46 -0
  37. data/spec/template/origin-fresh/hooks/pre-rebase.sample +169 -0
  38. data/spec/template/origin-fresh/hooks/prepare-commit-msg.sample +36 -0
  39. data/spec/template/origin-fresh/hooks/update.sample +128 -0
  40. data/spec/template/origin-fresh/info/exclude +6 -0
  41. data/spec/template/origin-fresh/objects/0a/da6d051b94cd0df50f5a0b7229aec26f0d2cdf +0 -0
  42. data/spec/template/origin-fresh/objects/0c/e06c616769768f09f5e629cfcc68eabe3dee81 +0 -0
  43. data/spec/template/origin-fresh/objects/20/049991cdafdce826f5a3c01e10ffa84d6997ec +0 -0
  44. data/spec/template/origin-fresh/objects/33/1d827fd47fb234af54e3a4bbf8c6705e9116cc +3 -0
  45. data/spec/template/origin-fresh/objects/41/51899b742fd6b1c873b177b9d13451682089bc +0 -0
  46. data/spec/template/origin-fresh/objects/44/ffd9c9c8b52b201659e3ad318cdad6ec836b46 +0 -0
  47. data/spec/template/origin-fresh/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 +0 -0
  48. data/spec/template/origin-fresh/objects/55/eeb01bdf874d1a35870bcf24a970c475c63344 +0 -0
  49. data/spec/template/origin-fresh/objects/8d/09f9b8d80ce282218125cb0cbf53cccf022203 +0 -0
  50. data/spec/template/origin-fresh/objects/b4/8e68d5cac189af36abe48e893d11c24b7b2a19 +0 -0
  51. data/spec/template/origin-fresh/objects/c0/838ed2ee8f2e83c8bda859fc5e332b92f0a5a3 +1 -0
  52. data/spec/template/origin-fresh/objects/cd/f7b9dbc4911a0d1404db54cde2ed448f6a6afd +0 -0
  53. data/spec/template/origin-fresh/objects/d2/6b33daea1ed9823a189992bba38fbc913483c1 +0 -0
  54. data/spec/template/origin-fresh/objects/fe/4e254557e19f338f40ccfdc00a7517771db880 +0 -0
  55. data/spec/template/origin-fresh/refs/heads/master +1 -0
  56. data/spec/template/origin-fresh/refs/heads/wip/USER/zombie-basic +1 -0
  57. metadata +61 -5
data/.autotest ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+
4
+ Autotest.add_hook :initialize do |at|
5
+ at.add_exception %r{tmp\/}
6
+ at.add_exception %r{template\/}
7
+ %w(.git).each do |ex|
8
+ at.add_exception ex
9
+ end
10
+ end
data/.vimrc CHANGED
@@ -1 +1,21 @@
1
- let $RUBYOPT = 'lib'
1
+ let $RUBYPATH = 'lib'
2
+
3
+ function! s:run_example()
4
+ if &ft != "ruby"
5
+ " Not ruby, do nothing.
6
+ return
7
+ endif
8
+
9
+ " look for it ", with no word character just before ‘it’
10
+ let line = search( '\w\@<!it "', "bnW" )
11
+ let cmd = "rspec --no-color " . expand( "%" ) . " -l " . line
12
+
13
+ if line > 0
14
+ execute "!" . cmd
15
+ else
16
+ echo "No rspec example found at or before cursor position."
17
+ endif
18
+ endfun
19
+ nmap <leader>t :call <SID>run_example()<CR>
20
+
21
+
data/Gemfile CHANGED
@@ -14,6 +14,8 @@ group :development do
14
14
  gem 'ZenTest'
15
15
  gem 'yard'
16
16
  gem 'gemcutter'
17
+
18
+ gem 'autotest-screen'
17
19
  end
18
20
 
19
21
 
data/Gemfile.lock CHANGED
@@ -3,6 +3,7 @@ GEM
3
3
  specs:
4
4
  ZenTest (4.3.3)
5
5
  activesupport (3.0.0.beta4)
6
+ autotest-screen (0.1.0.1)
6
7
  diff-lcs (1.1.2)
7
8
  gemcutter (0.5.0)
8
9
  json_pure
@@ -32,6 +33,7 @@ PLATFORMS
32
33
  DEPENDENCIES
33
34
  ZenTest
34
35
  activesupport (>= 3.0.0.beta4)
36
+ autotest-screen
35
37
  gemcutter
36
38
  jeweler
37
39
  rake
data/Rakefile CHANGED
@@ -3,16 +3,7 @@ require 'yaml'
3
3
  require 'rubygems'
4
4
  require 'rake'
5
5
 
6
- Dir[ 'lib/tasks/**/*' ].each{ |l| require l }
7
-
8
- # TODO 1: cleanup specs (possibly have specs setup repos, or possibly tar up
9
- # repos and extract them)
10
- # TODO 2: topic abandon <topic>
11
- # TODO 1: handle malformed args
12
- # TODO 1: git-topic comment
13
- # edit files & have the diffs pulled into notes?
14
-
15
- # TODO 1: git work-on <topic> should kill review branch
6
+ Dir[ 'lib/tasks/**/*' ].each{ |l| load l }
16
7
 
17
8
 
18
9
  begin
@@ -76,7 +67,9 @@ task 'version:write:build' do
76
67
  }
77
68
  v.merge!( y ) if y.is_a? Hash
78
69
  v[ :build ] = ENV['BUILD']
79
- File.open( "VERSION.yml", "w" ){|f| f.puts YAML::dump( v )}
70
+
71
+ v.each{|k,v| ENV[ k.to_s.upcase ] = v.to_s}
72
+ Rake::Task["version:write"].invoke
80
73
  end
81
74
 
82
75
  task 'version:bump:build' do
data/VERSION.yml CHANGED
@@ -2,4 +2,4 @@
2
2
  :major: 0
3
3
  :minor: 1
4
4
  :patch: 6
5
- :build: "3"
5
+ :build: "4"
data/bin/git-topic CHANGED
@@ -1,173 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
  # encoding: utf-8
3
3
 
4
- require 'yaml'
5
-
6
4
  require 'rubygems'
7
-
8
- require 'trollop'
9
5
  require 'git_topic'
10
-
11
-
12
- module GitTopic
13
- SubCommands = %w(work-on done status review accept reject install-aliases)
14
- Version = lambda {
15
- h = YAML::load_file( "#{File.dirname( __FILE__ )}/../VERSION.yml" )
16
- if h.is_a? Hash
17
- [h[:major], h[:minor], h[:patch], h[:build]].compact.join( "." )
18
- end
19
- }.call
20
-
21
- class << self
22
- def run
23
- global_opts = Trollop::options do
24
- banner "
25
- git-topic #{Version}
26
- Manage a topic/review workflow.
27
-
28
- see <http://github.com/hjdivad/git-topic>
29
-
30
- Commands are:
31
- #{SubCommands.join( "
32
- " )}
33
-
34
- Global Options:
35
- ".cleanup
36
- version Version
37
-
38
- opt :verbose, "Verbose output, including complete traces on errors."
39
- stop_on SubCommands
40
- end
41
-
42
- cmd = ARGV.shift
43
- cmd_opts = Trollop::options do
44
- case cmd
45
- when "work-on"
46
- banner "
47
- git work-on <topic>
48
- git-topic work-on <topic>
49
-
50
- Switches to a local work-in-progress (wip) branch for <topic>. The
51
- branch (and a matching remote branch) is created if necessary.
52
-
53
- If this is a rejected topic, work will continue from the state of
54
- the rejected topic branch.
55
-
56
- Options:
57
- ".cleanup
58
- when /done(-with)?/
59
- banner "
60
- git done
61
- git-topic done
62
-
63
- Indicate that this topic branch is ready for review. Push to a
64
- remote review branch and switch back to master.
65
-
66
- Options:
67
- ".cleanup
68
- when "status"
69
- banner "
70
- git st
71
- git-topic status
72
-
73
- Print a status, showing rejected branches to work on and branches
74
- that can be reviewed.
75
-
76
- Options:
77
- ".cleanup
78
- opt :prepended,
79
- "
80
- Prepend status to git status output (for a complete view of
81
- status).
82
- ".oneline,
83
- :default => false
84
- when "review"
85
- banner "
86
- git review [<topic>]
87
- git-topic reivew [<topic>]
88
-
89
- Review <topic>. If <topic> is unspecified, review the oldest (by HEAD) topic.
90
-
91
- Options:
92
- ".cleanup
93
- when "accept"
94
- banner "
95
- git accept
96
- git-topic accept
97
-
98
- Accept the current in-review topic, merging it to master and
99
- cleaning up the remote branch. This will fail if the branch does
100
- not merge as a fast-forward in master. If that happens, the topic
101
- should either be rejected, or you can manually rebase.
102
-
103
- Options:
104
- ".cleanup
105
- when "reject"
106
- banner "
107
- git reject
108
- git-topic reject
109
-
110
- Reject the current in-review topic.
111
-
112
- Options:
113
- ".cleanup
114
- when "install-aliases"
115
- banner "
116
- git-topic install-aliases
117
-
118
- Install aliases to make git topic nicer to work with. The aliases are as follows:
119
-
120
- w[ork-on] topic work-on
121
- done topic done
122
- r[eview] topic review
123
- accept topic accept
124
- reject topic reject
125
-
126
- st topic status --prepended
127
-
128
- Options:
129
- ".cleanup
130
-
131
- opt :local,
132
- "
133
- Install aliases non-globally (i.e. in .git/config instead of
134
- $HOME/.gitconfig
135
- ".oneline,
136
- :default => false
137
- end
138
- end
139
-
140
- opts = global_opts.merge( cmd_opts )
141
- display_git_output! if opts[:verbose]
142
-
143
- case cmd
144
- when "work-on"
145
- topic = ARGV.shift
146
- work_on topic, opts
147
- when /done(-with)?/
148
- topic = ARGV.shift
149
- done topic, opts
150
- when "status"
151
- status opts
152
- when "review"
153
- spec = ARGV.shift
154
- review spec, opts
155
- when "accept"
156
- topic = ARGV.shift
157
- accept topic, opts
158
- when "reject"
159
- topic = ARGV.shift
160
- reject topic, opts
161
- when "install-aliases"
162
- install_aliases opts
163
- end
164
- rescue => error
165
- puts "Error: #{error.message}"
166
- puts error.backtrace.join( "\n" ) if opts[:verbose]
167
- end
168
- end
169
- end
6
+ require 'git_topic/cli'
170
7
 
171
8
 
172
9
  GitTopic::run
173
-
data/git-topic ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+
5
+ # Do not run this file. It is for developer testing only. Use bin/git-topic.
6
+
7
+ $:.unshift "#{File.dirname(__FILE__)}/lib"
8
+ require 'git_topic'
9
+ require 'git_topic/cli'
10
+
11
+ require 'ruby-debug'
12
+
13
+ GitTopic::run
data/git-topic.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{git-topic}
8
- s.version = "0.1.6.3"
8
+ s.version = "0.1.6.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["David J. Hamilton"]
12
- s.date = %q{2010-07-14}
12
+ s.date = %q{2010-07-21}
13
13
  s.default_executable = %q{git-topic}
14
14
  s.description = %q{
15
15
  gem command around reviewed topic branches. Supports workflow of the form:
@@ -41,7 +41,8 @@ Gem::Specification.new do |s|
41
41
  "README.rdoc"
42
42
  ]
43
43
  s.files = [
44
- ".gitignore",
44
+ ".autotest",
45
+ ".gitignore",
45
46
  ".gvimrc",
46
47
  ".rspec",
47
48
  ".rvmrc",
@@ -56,14 +57,50 @@ Gem::Specification.new do |s|
56
57
  "VERSION.yml",
57
58
  "autotest/discover.rb",
58
59
  "bin/git-topic",
60
+ "git-topic",
59
61
  "git-topic.gemspec",
60
62
  "lib/core_ext.rb",
61
63
  "lib/git_topic.rb",
64
+ "lib/git_topic/cli.rb",
62
65
  "lib/git_topic/git.rb",
63
66
  "lib/git_topic/naming.rb",
67
+ "lib/tasks/annotations.rake",
64
68
  "spec/git_topic_spec.rb",
65
69
  "spec/spec_helper.rb",
70
+ "spec/template/origin-fresh/HEAD",
71
+ "spec/template/origin-fresh/RENAMED-REF",
72
+ "spec/template/origin-fresh/config",
73
+ "spec/template/origin-fresh/description",
74
+ "spec/template/origin-fresh/hooks/applypatch-msg.sample",
75
+ "spec/template/origin-fresh/hooks/commit-msg.sample",
76
+ "spec/template/origin-fresh/hooks/post-commit.sample",
77
+ "spec/template/origin-fresh/hooks/post-receive.sample",
78
+ "spec/template/origin-fresh/hooks/post-update.sample",
79
+ "spec/template/origin-fresh/hooks/pre-applypatch.sample",
80
+ "spec/template/origin-fresh/hooks/pre-commit.sample",
81
+ "spec/template/origin-fresh/hooks/pre-rebase.sample",
82
+ "spec/template/origin-fresh/hooks/prepare-commit-msg.sample",
83
+ "spec/template/origin-fresh/hooks/update.sample",
84
+ "spec/template/origin-fresh/info/exclude",
85
+ "spec/template/origin-fresh/objects/0a/da6d051b94cd0df50f5a0b7229aec26f0d2cdf",
86
+ "spec/template/origin-fresh/objects/0c/e06c616769768f09f5e629cfcc68eabe3dee81",
87
+ "spec/template/origin-fresh/objects/20/049991cdafdce826f5a3c01e10ffa84d6997ec",
88
+ "spec/template/origin-fresh/objects/33/1d827fd47fb234af54e3a4bbf8c6705e9116cc",
89
+ "spec/template/origin-fresh/objects/41/51899b742fd6b1c873b177b9d13451682089bc",
90
+ "spec/template/origin-fresh/objects/44/ffd9c9c8b52b201659e3ad318cdad6ec836b46",
91
+ "spec/template/origin-fresh/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904",
92
+ "spec/template/origin-fresh/objects/55/eeb01bdf874d1a35870bcf24a970c475c63344",
93
+ "spec/template/origin-fresh/objects/8d/09f9b8d80ce282218125cb0cbf53cccf022203",
94
+ "spec/template/origin-fresh/objects/b4/8e68d5cac189af36abe48e893d11c24b7b2a19",
95
+ "spec/template/origin-fresh/objects/c0/838ed2ee8f2e83c8bda859fc5e332b92f0a5a3",
96
+ "spec/template/origin-fresh/objects/cd/f7b9dbc4911a0d1404db54cde2ed448f6a6afd",
97
+ "spec/template/origin-fresh/objects/d2/6b33daea1ed9823a189992bba38fbc913483c1",
98
+ "spec/template/origin-fresh/objects/fe/4e254557e19f338f40ccfdc00a7517771db880",
99
+ "spec/template/origin-fresh/refs/heads/master",
100
+ "spec/template/origin-fresh/refs/heads/wip/USER/zombie-basic",
66
101
  "spec/template/origin/HEAD",
102
+ "spec/template/origin/ORIG_HEAD",
103
+ "spec/template/origin/RENAMED-REF",
67
104
  "spec/template/origin/config",
68
105
  "spec/template/origin/description",
69
106
  "spec/template/origin/hooks/applypatch-msg.sample",
@@ -80,22 +117,28 @@ Gem::Specification.new do |s|
80
117
  "spec/template/origin/objects/0a/da6d051b94cd0df50f5a0b7229aec26f0d2cdf",
81
118
  "spec/template/origin/objects/0c/e06c616769768f09f5e629cfcc68eabe3dee81",
82
119
  "spec/template/origin/objects/20/049991cdafdce826f5a3c01e10ffa84d6997ec",
120
+ "spec/template/origin/objects/2d/a16986c7f742f808a3a3e68108bd2e4dae009d",
83
121
  "spec/template/origin/objects/33/1d827fd47fb234af54e3a4bbf8c6705e9116cc",
84
122
  "spec/template/origin/objects/41/51899b742fd6b1c873b177b9d13451682089bc",
85
123
  "spec/template/origin/objects/44/ffd9c9c8b52b201659e3ad318cdad6ec836b46",
86
124
  "spec/template/origin/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904",
87
125
  "spec/template/origin/objects/55/eeb01bdf874d1a35870bcf24a970c475c63344",
126
+ "spec/template/origin/objects/65/3d7112dadcacaaae6390612eac58c234f92b18",
88
127
  "spec/template/origin/objects/8d/09f9b8d80ce282218125cb0cbf53cccf022203",
89
128
  "spec/template/origin/objects/b4/8e68d5cac189af36abe48e893d11c24b7b2a19",
90
129
  "spec/template/origin/objects/c0/838ed2ee8f2e83c8bda859fc5e332b92f0a5a3",
91
130
  "spec/template/origin/objects/cd/f7b9dbc4911a0d1404db54cde2ed448f6a6afd",
92
131
  "spec/template/origin/objects/d2/6b33daea1ed9823a189992bba38fbc913483c1",
132
+ "spec/template/origin/objects/dd/26afde91bbae18e13e4df1cd1da56a75ccc665",
93
133
  "spec/template/origin/objects/fe/4e254557e19f338f40ccfdc00a7517771db880",
94
134
  "spec/template/origin/refs/heads/master",
95
- "spec/template/origin/refs/heads/rejected/davidjh/krakens",
96
- "spec/template/origin/refs/heads/review/davidjh/pirates",
135
+ "spec/template/origin/refs/heads/rejected/USER/krakens",
136
+ "spec/template/origin/refs/heads/review/USER/pirates",
97
137
  "spec/template/origin/refs/heads/review/user24601/ninja-basic",
98
- "spec/template/origin/refs/heads/review/user24601/zombie-basic"
138
+ "spec/template/origin/refs/heads/review/user24601/zombie-basic",
139
+ "spec/template/origin/refs/heads/wip/USER/pirates-advanced",
140
+ "spec/template/origin/refs/heads/wip/USER/zombie-basic",
141
+ "spec/template/origin/refs/heads/wip/prevent-ff"
99
142
  ]
100
143
  s.homepage = %q{http://github.com/hjdivad/git-topic}
101
144
  s.rdoc_options = ["--charset=UTF-8"]
@@ -120,6 +163,7 @@ Gem::Specification.new do |s|
120
163
  s.add_development_dependency(%q<ZenTest>, [">= 0"])
121
164
  s.add_development_dependency(%q<yard>, [">= 0"])
122
165
  s.add_development_dependency(%q<gemcutter>, [">= 0"])
166
+ s.add_development_dependency(%q<autotest-screen>, [">= 0"])
123
167
  else
124
168
  s.add_dependency(%q<activesupport>, [">= 3.0.0.beta4"])
125
169
  s.add_dependency(%q<trollop>, [">= 0"])
@@ -129,6 +173,7 @@ Gem::Specification.new do |s|
129
173
  s.add_dependency(%q<ZenTest>, [">= 0"])
130
174
  s.add_dependency(%q<yard>, [">= 0"])
131
175
  s.add_dependency(%q<gemcutter>, [">= 0"])
176
+ s.add_dependency(%q<autotest-screen>, [">= 0"])
132
177
  end
133
178
  else
134
179
  s.add_dependency(%q<activesupport>, [">= 3.0.0.beta4"])
@@ -139,6 +184,7 @@ Gem::Specification.new do |s|
139
184
  s.add_dependency(%q<ZenTest>, [">= 0"])
140
185
  s.add_dependency(%q<yard>, [">= 0"])
141
186
  s.add_dependency(%q<gemcutter>, [">= 0"])
187
+ s.add_dependency(%q<autotest-screen>, [">= 0"])
142
188
  end
143
189
  end
144
190
 
@@ -0,0 +1,171 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ require 'yaml'
5
+
6
+ require 'rubygems'
7
+
8
+ require 'trollop'
9
+ require 'git_topic'
10
+
11
+
12
+ module GitTopic
13
+ SubCommands = %w(work-on done status review accept reject install-aliases)
14
+ Version = lambda {
15
+ h = YAML::load_file( "#{File.dirname( __FILE__ )}/../../VERSION.yml" )
16
+ if h.is_a? Hash
17
+ [h[:major], h[:minor], h[:patch], h[:build]].compact.join( "." )
18
+ end
19
+ }.call
20
+
21
+ class << self
22
+ def run
23
+ global_opts = self.global_opts = Trollop::options do
24
+ banner "
25
+ git-topic #{Version}
26
+ Manage a topic/review workflow.
27
+
28
+ see <http://github.com/hjdivad/git-topic>
29
+
30
+ Commands are:
31
+ #{SubCommands.join( "
32
+ " )}
33
+
34
+ Global Options:
35
+ ".cleanup
36
+ version Version
37
+
38
+ opt :verbose, "Verbose output, including complete traces on errors."
39
+ stop_on SubCommands
40
+ end
41
+
42
+ cmd = ARGV.shift
43
+ cmd_opts = Trollop::options do
44
+ case cmd
45
+ when "work-on"
46
+ banner "
47
+ git work-on <topic>
48
+ git-topic work-on <topic>
49
+
50
+ Switches to a local work-in-progress (wip) branch for <topic>. The
51
+ branch (and a matching remote branch) is created if necessary.
52
+
53
+ If this is a rejected topic, work will continue from the state of
54
+ the rejected topic branch.
55
+
56
+ Options:
57
+ ".cleanup
58
+ when /done(-with)?/
59
+ banner "
60
+ git done
61
+ git-topic done
62
+
63
+ Indicate that this topic branch is ready for review. Push to a
64
+ remote review branch and switch back to master.
65
+
66
+ Options:
67
+ ".cleanup
68
+ when "status"
69
+ banner "
70
+ git st
71
+ git-topic status
72
+
73
+ Print a status, showing rejected branches to work on and branches
74
+ that can be reviewed.
75
+
76
+ Options:
77
+ ".cleanup
78
+ opt :prepended,
79
+ "
80
+ Prepend status to git status output (for a complete view of
81
+ status).
82
+ ".oneline,
83
+ :default => false
84
+ when "review"
85
+ banner "
86
+ git review [<topic>]
87
+ git-topic reivew [<topic>]
88
+
89
+ Review <topic>. If <topic> is unspecified, review the oldest (by HEAD) topic.
90
+
91
+ Options:
92
+ ".cleanup
93
+ when "accept"
94
+ banner "
95
+ git accept
96
+ git-topic accept
97
+
98
+ Accept the current in-review topic, merging it to master and
99
+ cleaning up the remote branch. This will fail if the branch does
100
+ not merge as a fast-forward in master. If that happens, the topic
101
+ should either be rejected, or you can manually rebase.
102
+
103
+ Options:
104
+ ".cleanup
105
+ when "reject"
106
+ banner "
107
+ git reject
108
+ git-topic reject
109
+
110
+ Reject the current in-review topic.
111
+
112
+ Options:
113
+ ".cleanup
114
+ when "install-aliases"
115
+ banner "
116
+ git-topic install-aliases
117
+
118
+ Install aliases to make git topic nicer to work with. The aliases are as follows:
119
+
120
+ w[ork-on] topic work-on
121
+ done topic done
122
+ r[eview] topic review
123
+ accept topic accept
124
+ reject topic reject
125
+
126
+ st topic status --prepended
127
+
128
+ Options:
129
+ ".cleanup
130
+
131
+ opt :local,
132
+ "
133
+ Install aliases non-globally (i.e. in .git/config instead of
134
+ $HOME/.gitconfig
135
+ ".oneline,
136
+ :default => false
137
+ end
138
+ end
139
+
140
+ opts = global_opts.merge( cmd_opts )
141
+ display_git_output! if opts[:verbose]
142
+
143
+ case cmd
144
+ when "work-on"
145
+ topic = ARGV.shift
146
+ work_on topic, opts
147
+ when /done(-with)?/
148
+ topic = ARGV.shift
149
+ done topic, opts
150
+ when "status"
151
+ status opts
152
+ when "review"
153
+ spec = ARGV.shift
154
+ review spec, opts
155
+ when "accept"
156
+ topic = ARGV.shift
157
+ accept topic, opts
158
+ when "reject"
159
+ topic = ARGV.shift
160
+ reject topic, opts
161
+ when "install-aliases"
162
+ install_aliases opts
163
+ end
164
+ rescue => error
165
+ puts "Error: #{error.message}"
166
+ puts error.backtrace.join( "\n" ) if opts[:verbose]
167
+ end
168
+ end
169
+ end
170
+
171
+
data/lib/git_topic/git.rb CHANGED
@@ -1,5 +1,9 @@
1
1
 
2
- module GitTopic; end
2
+ module GitTopic
3
+ class << self; attr_accessor :global_opts end
4
+ self.global_opts = {}
5
+ end
6
+
3
7
  module GitTopic::Git
4
8
  module ClassMethods
5
9
 
@@ -41,13 +45,19 @@ module GitTopic::Git
41
45
  def git( cmds=[], opts={} )
42
46
  cmds = [cmds] if cmds.is_a? String
43
47
  redir = cmd_redirect_suffix( opts )
44
- system cmds.map{|c| "git #{c} #{redir}"}.join( " && " )
48
+ cmd = cmds.map{|c| "git #{c} #{redir}"}.join( " && " )
49
+
50
+ puts cmd if GitTopic::global_opts[:verbose]
51
+ system cmd
45
52
  end
46
53
 
47
54
  def capture_git( cmds=[] )
48
55
  cmds = [cmds] if cmds.is_a? String
49
56
  redir = "2> /dev/null" unless display_git_output?
50
- `#{cmds.map{|c| "git #{c} #{redir}"}.join( " && " )}`
57
+ cmd = "#{cmds.map{|c| "git #{c} #{redir}"}.join( " && " )}"
58
+
59
+ puts cmd if GitTopic::global_opts[:verbose]
60
+ `#{cmd}`
51
61
  end
52
62
 
53
63
  end
@@ -7,23 +7,23 @@ module GitTopic::Naming
7
7
  protected
8
8
 
9
9
  def backup_branch( topic )
10
- "backup/#{user}/#{topic}"
10
+ "backup/#{user}/#{strip_namespace topic}"
11
11
  end
12
12
 
13
13
  def wip_branch( topic )
14
- "wip/#{user}/#{topic}"
14
+ "wip/#{user}/#{strip_namespace topic}"
15
15
  end
16
16
 
17
17
  def rejected_branch( topic )
18
- "rejected/#{user}/#{topic}"
18
+ "rejected/#{user}/#{strip_namespace topic}"
19
19
  end
20
20
 
21
21
  def review_branch( topic, user=user )
22
- "review/#{user}/#{topic}"
22
+ "review/#{user}/#{strip_namespace topic}"
23
23
  end
24
24
 
25
25
  def remote_rejected_branch( topic, user=user )
26
- "rejected/#{user}/#{topic}"
26
+ "rejected/#{user}/#{strip_namespace topic}"
27
27
  end
28
28
 
29
29
 
@@ -31,6 +31,14 @@ module GitTopic::Naming
31
31
  others_review_branches.find{|b| b.index topic}
32
32
  end
33
33
 
34
+ def strip_namespace( ref )
35
+ if ref =~ %r{(?:wip|rejected|review)/\S*/(.*)}
36
+ $1
37
+ else
38
+ ref
39
+ end
40
+ end
41
+
34
42
 
35
43
  def user_topic_name( branch )
36
44
  if branch =~ %r{^origin}
@@ -42,16 +50,16 @@ module GitTopic::Naming
42
50
  end
43
51
  end
44
52
 
45
- def topic_parts( spec )
53
+ def topic_parts( ref )
46
54
  p = {}
47
- parts = spec.split( '/' )
55
+ parts = ref.split( '/' )
48
56
  case parts.size
49
57
  when 2
50
58
  p[:user], p[:topic] = parts
51
59
  when 1
52
60
  p[:topic] = parts.first
53
61
  else
54
- raise "Unexpected topic: #{spec}"
62
+ raise "Unexpected topic: #{ref}"
55
63
  end
56
64
  p
57
65
  end