git-topic 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. data/.gitignore +4 -0
  2. data/.gvimrc +23 -0
  3. data/.rspec +1 -0
  4. data/.rvmrc +1 -0
  5. data/.vimproject +26 -0
  6. data/.vimrc +1 -0
  7. data/Gemfile +19 -0
  8. data/Gemfile.lock +63 -0
  9. data/History.txt +6 -0
  10. data/LICENSE +20 -0
  11. data/README.rdoc +192 -0
  12. data/Rakefile +62 -0
  13. data/VERSION +1 -0
  14. data/autotest/discover.rb +1 -0
  15. data/bin/git-topic +143 -0
  16. data/git-topic.gemspec +127 -0
  17. data/lib/git-topic.rb +375 -0
  18. data/lib/util.rb +34 -0
  19. data/spec/git-topic_spec.rb +378 -0
  20. data/spec/spec_helper.rb +56 -0
  21. data/spec/template/origin/HEAD +1 -0
  22. data/spec/template/origin/config +7 -0
  23. data/spec/template/origin/description +1 -0
  24. data/spec/template/origin/hooks/applypatch-msg.sample +15 -0
  25. data/spec/template/origin/hooks/commit-msg.sample +24 -0
  26. data/spec/template/origin/hooks/post-commit.sample +8 -0
  27. data/spec/template/origin/hooks/post-receive.sample +15 -0
  28. data/spec/template/origin/hooks/post-update.sample +8 -0
  29. data/spec/template/origin/hooks/pre-applypatch.sample +14 -0
  30. data/spec/template/origin/hooks/pre-commit.sample +46 -0
  31. data/spec/template/origin/hooks/pre-rebase.sample +169 -0
  32. data/spec/template/origin/hooks/prepare-commit-msg.sample +36 -0
  33. data/spec/template/origin/hooks/update.sample +128 -0
  34. data/spec/template/origin/info/exclude +6 -0
  35. data/spec/template/origin/objects/0a/da6d051b94cd0df50f5a0b7229aec26f0d2cdf +0 -0
  36. data/spec/template/origin/objects/0c/e06c616769768f09f5e629cfcc68eabe3dee81 +0 -0
  37. data/spec/template/origin/objects/20/049991cdafdce826f5a3c01e10ffa84d6997ec +0 -0
  38. data/spec/template/origin/objects/33/1d827fd47fb234af54e3a4bbf8c6705e9116cc +3 -0
  39. data/spec/template/origin/objects/41/51899b742fd6b1c873b177b9d13451682089bc +0 -0
  40. data/spec/template/origin/objects/44/ffd9c9c8b52b201659e3ad318cdad6ec836b46 +0 -0
  41. data/spec/template/origin/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 +0 -0
  42. data/spec/template/origin/objects/55/eeb01bdf874d1a35870bcf24a970c475c63344 +0 -0
  43. data/spec/template/origin/objects/8d/09f9b8d80ce282218125cb0cbf53cccf022203 +0 -0
  44. data/spec/template/origin/objects/b4/8e68d5cac189af36abe48e893d11c24b7b2a19 +0 -0
  45. data/spec/template/origin/objects/c0/838ed2ee8f2e83c8bda859fc5e332b92f0a5a3 +1 -0
  46. data/spec/template/origin/objects/cd/f7b9dbc4911a0d1404db54cde2ed448f6a6afd +0 -0
  47. data/spec/template/origin/objects/d2/6b33daea1ed9823a189992bba38fbc913483c1 +0 -0
  48. data/spec/template/origin/objects/fe/4e254557e19f338f40ccfdc00a7517771db880 +0 -0
  49. data/spec/template/origin/refs/heads/master +1 -0
  50. data/spec/template/origin/refs/heads/rejected/davidjh/krakens +1 -0
  51. data/spec/template/origin/refs/heads/review/davidjh/pirates +1 -0
  52. data/spec/template/origin/refs/heads/review/user24601/ninja-basic +1 -0
  53. data/spec/template/origin/refs/heads/review/user24601/zombie-basic +1 -0
  54. metadata +158 -0
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ /tmp
2
+ /pkg
3
+ /.yardoc
4
+ /doc
data/.gvimrc ADDED
@@ -0,0 +1,23 @@
1
+ """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2
+ " Setup tabs and vimproject
3
+
4
+ Project .vimproject
5
+
6
+ tabnew
7
+ tabnew
8
+ tabnew
9
+ tabnew
10
+ tabnew
11
+ tabnew
12
+ tabnew
13
+ tabnew
14
+ tabnew
15
+
16
+ tabdo Project
17
+ tabdo wincmd l
18
+ tabdo wincmd n
19
+
20
+ 1tabn
21
+ """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
22
+
23
+ winpos 433 25
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm 1.9.2-rc1
data/.vimproject ADDED
@@ -0,0 +1,26 @@
1
+ project=$PWD cd=. {
2
+ History.txt
3
+ LICENSE
4
+ README.rdoc
5
+ README.txt
6
+ Rakefile
7
+ bin=bin {
8
+ git-topic
9
+ }
10
+ lib=lib {
11
+ git-topic.rb
12
+ util.rb
13
+ }
14
+ spec=spec {
15
+ git-topic_spec.rb
16
+ spec_helper.rb
17
+ }
18
+ }
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+ vim:wfw fdl=1:
data/.vimrc ADDED
@@ -0,0 +1 @@
1
+ let $RUBYOPT = 'lib'
data/Gemfile ADDED
@@ -0,0 +1,19 @@
1
+ # encoding: utf-8
2
+
3
+ source :gemcutter
4
+
5
+ gem 'activesupport'
6
+ gem 'trollop'
7
+ gem 'gemcutter'
8
+
9
+ group :development do
10
+ gem 'jeweler'
11
+ gem 'rake'
12
+ gem 'rspec', '>= 2.0.0.beta.16'
13
+ gem 'ZenTest'
14
+ gem 'yard'
15
+ end
16
+
17
+
18
+
19
+ # vim:ft=ruby:
data/Gemfile.lock ADDED
@@ -0,0 +1,63 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ ZenTest (4.3.3)
5
+ ZenTest (4.3.3)
6
+ activesupport (2.3.8)
7
+ activesupport (2.3.8)
8
+ diff-lcs (1.1.2)
9
+ diff-lcs (1.1.2)
10
+ gemcutter (0.5.0)
11
+ json_pure
12
+ gemcutter (0.5.0)
13
+ json_pure
14
+ git (1.2.5)
15
+ git (1.2.5)
16
+ jeweler (1.4.0)
17
+ gemcutter (>= 0.1.0)
18
+ git (>= 1.2.5)
19
+ rubyforge (>= 2.0.0)
20
+ jeweler (1.4.0)
21
+ gemcutter (>= 0.1.0)
22
+ git (>= 1.2.5)
23
+ rubyforge (>= 2.0.0)
24
+ json_pure (1.4.3)
25
+ json_pure (1.4.3)
26
+ rake (0.8.7)
27
+ rake (0.8.7)
28
+ rspec (2.0.0.beta.16)
29
+ rspec-core (= 2.0.0.beta.16)
30
+ rspec-expectations (= 2.0.0.beta.16)
31
+ rspec-mocks (= 2.0.0.beta.16)
32
+ rspec (2.0.0.beta.16)
33
+ rspec-core (= 2.0.0.beta.16)
34
+ rspec-expectations (= 2.0.0.beta.16)
35
+ rspec-mocks (= 2.0.0.beta.16)
36
+ rspec-core (2.0.0.beta.16)
37
+ rspec-core (2.0.0.beta.16)
38
+ rspec-expectations (2.0.0.beta.16)
39
+ diff-lcs (>= 1.1.2)
40
+ rspec-expectations (2.0.0.beta.16)
41
+ diff-lcs (>= 1.1.2)
42
+ rspec-mocks (2.0.0.beta.16)
43
+ rspec-mocks (2.0.0.beta.16)
44
+ rubyforge (2.0.4)
45
+ json_pure (>= 1.1.7)
46
+ rubyforge (2.0.4)
47
+ json_pure (>= 1.1.7)
48
+ trollop (1.16.2)
49
+ trollop (1.16.2)
50
+ yard (0.5.8)
51
+
52
+ PLATFORMS
53
+ ruby
54
+
55
+ DEPENDENCIES
56
+ ZenTest
57
+ activesupport
58
+ gemcutter
59
+ jeweler
60
+ rake
61
+ rspec (>= 2.0.0.beta.16)
62
+ trollop
63
+ yard
data/History.txt ADDED
@@ -0,0 +1,6 @@
1
+ === 1.0.0 / 2010-03-05
2
+
3
+ * 1 major enhancement
4
+
5
+ * Birthday!
6
+
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 David J. Hamilton
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.rdoc ADDED
@@ -0,0 +1,192 @@
1
+ = git-topic
2
+
3
+ git-topic is a git command to help with a particular kind of workflow, in which
4
+ all work is written by an author, and reviewed by someone else.
5
+
6
+ == Workflow in brief
7
+
8
+ === Doing Work
9
+
10
+ 1. Create a topic branch in the wip namespace.
11
+ 2. Do some work.
12
+ 3. Rebase to create a nice commit history.
13
+ 4. Push to the review namespace. If the wip branch was pushed (e.g.
14
+ because you work on multiple machines) destroy it on the remote.
15
+
16
+ 1. Create a local branch from a rejected branch.
17
+ 2. Do some work, resolve the reviewer's issues.
18
+ 3. go to step 3, above.
19
+
20
+ === Reviewing
21
+
22
+ 1. Create a local branch from a review branch somebody else pushed.
23
+ 2. Review their work.
24
+ 3. a.i. Accept; merge (fast-forward) master
25
+ ii. Destroy the review branch.
26
+ b. Reject; add notes and push to the rejected namespace and remove from
27
+ the review namespace.
28
+
29
+
30
+ == Workflow without git-topic
31
+
32
+ === Working on a topic (e.g. feature, or bugfix) foo
33
+
34
+ # Create a new branch and switch to it.
35
+ git checkout -b wip/hal/foo
36
+
37
+ # do some work, create lots of temporary commits
38
+ # when ready to get the code into master, first update so we're rebasing against
39
+ # the latest code
40
+ git fetch origin
41
+
42
+ # rebase against latest code
43
+ git rebase --interactive origin/master
44
+
45
+ # when done rebasing so wip/hal/foo now has a nice clean commit history, push to
46
+ # a review branch and destroy the remote wip branch
47
+ git push origin wip/hal/foo:review/hal/foo :wip/hal/foo
48
+
49
+ # alternatively if you never pushed your wip branch to the remote there's no
50
+ # need to destroy it, instead only push your local wip branch as a review branch
51
+ #
52
+ # git push origin wip/hal/foo:review/hal/foo
53
+
54
+
55
+ # later, after your changes have been merged into master, you can delete your
56
+ # local branch
57
+ #
58
+ # git checkout master
59
+ # git branch -d wip/hal/foo
60
+
61
+
62
+
63
+ === Reviewing a topic (no proposed changes)
64
+
65
+ # update origin
66
+ git fetch origin
67
+
68
+ # notice there's a review branch
69
+ git branch -r
70
+
71
+ # create a local branch that tracks the remote review branch
72
+ git checkout -b review/djh/bar origin/review/djh/bar
73
+
74
+ # examine code and examine the local (proposed) commits
75
+ git log master..
76
+
77
+ # when done reviewing, merge into master
78
+ git checkout master
79
+ # This should be a fast-forward merge. If not, it's because something has been
80
+ # added to master since the rebase
81
+ git merge review/djh/bar
82
+ git branch -d review/djh/bar
83
+
84
+ # update the new master and destroy the old review branch
85
+ git push origin master :review/djh/bar
86
+
87
+
88
+
89
+ === Reviewing a topc (proposed changes)
90
+
91
+ As above, but if, after examining the code you feel some changes are
92
+ appropriate, you can either:
93
+
94
+ 1. do them yourself and have the other person review and merge
95
+
96
+ # do some changes, then destroy the old review branch and make a new one
97
+ # with the cleaned up code. Now the owner is changed from djh to hal, so
98
+ # djh must review and merge into master
99
+ git push origin review/djh/bar:review/hal/bar :review/djh/bar
100
+
101
+ 2. do some (or no) changes, but with some TODOs for the original author.
102
+
103
+ # do your changes on review/djh/bar
104
+
105
+ # then update the remote, moving the branch to rejected, indicating the
106
+ # author has some TODOs left.
107
+ git push origin review/djh/bar:rejected/djh/bar :review/djh/bar
108
+
109
+ # when the author has resolved the TODOs they will move the branch back to
110
+ # review/djh/bar
111
+
112
+
113
+ == Workflow with git-topic
114
+
115
+ === Doing Work
116
+
117
+ # Work on a (possibly new, possibly rejected) topic
118
+ git topic work-on <topic>
119
+
120
+ # done with topic; push it for someone to review
121
+ git topic done [<topic>]
122
+
123
+
124
+ === Reviewing
125
+
126
+ # see if we have any topics to review (or rejected topics to fix up)
127
+ git topic status
128
+
129
+ git topic review [<topic>]
130
+
131
+ # happy with the review, get it into master
132
+ git topic accept
133
+
134
+ # unhappy with the review, push it to rejected
135
+ git topic reject
136
+
137
+ == Again, but with aliases
138
+
139
+ # first install aliases
140
+ # add --local if you don't want to update your global aliases
141
+ git topic install-aliases
142
+
143
+ # alternatively
144
+ # git w <topic>
145
+ git work-on <topic>
146
+
147
+ git done
148
+
149
+
150
+ # does status --prepend so you get git status output as well as git topic
151
+ # status
152
+ git st
153
+
154
+ # alternatively
155
+ # git r <topic>
156
+ git review <topic>
157
+
158
+ git accept
159
+ # or
160
+ git reject
161
+
162
+ == Misc
163
+
164
+ At present the binary is stupidly slow. Actually, the binary is not slow, but
165
+ all rubygems binaries are slow. See ruby issue 3465[1]. One way around this is
166
+ to modify yor PATH so you invoke the binary directly (instead of the rubygem
167
+ wrapper). Alternatively, put up with a 300ms load time until you have a ruby
168
+ with the issue fixed.
169
+
170
+ == Obvious Features Missing
171
+
172
+ 1. shell autocomplete
173
+
174
+
175
+ == Note on Patches/Pull Requests
176
+
177
+ 1. Fork the project.
178
+ 2. Make your feature addition or bug fix.
179
+ 3. Add tests for it. This is important so I don't break it in a
180
+ future version unintentionally.
181
+ 4. Commit, do not mess with rakefile, version, or history. (if you want to
182
+ have your own version, that is fine but bump version in a commit by itself I
183
+ can ignore when I pull)
184
+ 5. Send me a pull request. Bonus points for topic branches.
185
+
186
+ == Copyright
187
+
188
+ Copyright (c) 2010 David J. Hamilton. See LICENSE for details.
189
+
190
+ == References
191
+
192
+ [1] http://redmine.ruby-lang.org/issues/show/3465
data/Rakefile ADDED
@@ -0,0 +1,62 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ Dir[ 'lib/tasks/**/*' ].each{ |l| require l }
5
+
6
+
7
+ begin
8
+ require 'jeweler'
9
+ Jeweler::Tasks.new do |gem|
10
+ gem.name = "git-topic"
11
+ gem.summary = %Q{git command around reviewed topic branches}
12
+ gem.description = %Q{
13
+ gem command around reviewed topic branches. Supports workflow of the form:
14
+
15
+ # alexander:
16
+ git work-on <topic>
17
+ git done
18
+
19
+ # bismarck:
20
+ git status # notice a review branch
21
+ git review <topic>
22
+ # happy, merge into master, push and cleanup
23
+ git accept
24
+
25
+ git review <topic2>
26
+ # unhappy
27
+ git reject
28
+
29
+ # alexander:
30
+ git status # notice rejected topic
31
+ git work-on <topic>
32
+
33
+ see README.rdoc for more (any) details.
34
+ }
35
+ gem.email = "git-topic@hjdivad.com"
36
+ gem.homepage = "http://github.com/hjdivad/git-topic"
37
+ gem.authors = ["David J. Hamilton"]
38
+ gem.add_development_dependency "rspec", ">= 1.2.9"
39
+ gem.add_development_dependency "yard", ">= 0"
40
+ gem.add_development_dependency "cucumber", ">= 0"
41
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
42
+ end
43
+ Jeweler::GemcutterTasks.new
44
+ rescue LoadError
45
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
46
+ end
47
+
48
+ desc "Run all specs."
49
+ task :spec do
50
+ sh "bundle exec rspec spec"
51
+ end
52
+
53
+
54
+ begin
55
+ require 'yard'
56
+ YARD::Rake::YardocTask.new
57
+ rescue LoadError
58
+ desc "Try (and fail) to run yardoc to get an error message."
59
+ task :yard do
60
+ abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
61
+ end
62
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.1
@@ -0,0 +1 @@
1
+ Autotest.add_discovery { "rspec2" }
data/bin/git-topic ADDED
@@ -0,0 +1,143 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ require 'trollop'
5
+ require 'git-topic'
6
+
7
+
8
+ module GitTopic
9
+ SubCommands = %w(work-on done status review accept reject install-aliases)
10
+
11
+ class << self
12
+ def run
13
+ global_opts = Trollop::options do
14
+ banner "
15
+ Manage a topic/review workflow.
16
+
17
+ Commands are:
18
+ #{SubCommands.join( "
19
+ " )}
20
+
21
+ Global Options:
22
+ ".cleanup
23
+
24
+ opt :verbose, "Verbose output, including complete traces on errors."
25
+ stop_on SubCommands
26
+ end
27
+
28
+ cmd = ARGV.shift
29
+ cmd_opts = Trollop::options do
30
+ case cmd
31
+ when "work-on"
32
+ banner "
33
+ work-on <topic>
34
+
35
+ Switches to a local work-in-progress (wip) branch for <topic>. The
36
+ branch (and a matching remote branch) is created if necessary.
37
+
38
+ If this is a rejected topic, work will continue from the state of
39
+ the rejected topic branch.
40
+ ".cleanup
41
+ when /done(-with)?/
42
+ banner "
43
+ done
44
+
45
+ Indicate that this topic branch is ready for review. Push to a
46
+ remote review branch and switch back to master.
47
+ ".cleanup
48
+ when "status"
49
+ banner "
50
+ status
51
+
52
+ Print a status, showing rejected branches to work on and branches
53
+ that can be reviewed.
54
+
55
+ Options:
56
+ ".cleanup
57
+ opt :prepended,
58
+ "
59
+ Prepend status to git status output (for a complete view of
60
+ status).
61
+ ".oneline,
62
+ :default => false
63
+ when "review"
64
+ banner "
65
+ review [<topic>]
66
+
67
+ Review <topic>. If <topic> is unspecified, review the oldest (by HEAD) topic.
68
+ ".cleanup
69
+ when "accept"
70
+ banner "
71
+ accept
72
+
73
+ Accept the current in-review topic, merging it to master and
74
+ cleaning up the remote branch. This will fail if the branch does
75
+ not merge as a fast-forward in master. If that happens, the topic
76
+ should either be rejected, or you can manually rebase.
77
+ ".cleanup
78
+ when "reject"
79
+ banner "
80
+ reject
81
+
82
+ Reject the current in-review topic.
83
+ ".cleanup
84
+ when "install-aliases"
85
+ banner "
86
+ install-aliases
87
+
88
+ Install aliases to make git topic nicer to work with. The aliases are as follows:
89
+
90
+ w[ork-on] topic work-on
91
+ done topic done
92
+ r[eview] topic review
93
+ accept topic accept
94
+ reject topic reject
95
+
96
+ st topic status --prepended
97
+
98
+ Options:
99
+ ".cleanup
100
+
101
+ opt :local,
102
+ "
103
+ Install aliases non-globally (i.e. in .git/config instead of
104
+ $HOME/.gitconfig
105
+ ".oneline,
106
+ :default => false
107
+ end
108
+ end
109
+
110
+ opts = global_opts.merge( cmd_opts )
111
+ display_git_output! if opts[:verbose]
112
+
113
+ case cmd
114
+ when "work-on"
115
+ topic = ARGV.shift
116
+ work_on topic, opts
117
+ when /done(-with)?/
118
+ topic = ARGV.shift
119
+ done topic, opts
120
+ when "status"
121
+ status opts
122
+ when "review"
123
+ spec = ARGV.shift
124
+ review spec, opts
125
+ when "accept"
126
+ topic = ARGV.shift
127
+ accept topic, opts
128
+ when "reject"
129
+ topic = ARGV.shift
130
+ reject topic, opts
131
+ when "install-aliases"
132
+ install_aliases opts
133
+ end
134
+ rescue => error
135
+ puts "Error: #{error.message}"
136
+ puts error.backtrace.join( "\n" ) if opts[:verbose]
137
+ end
138
+ end
139
+ end
140
+
141
+
142
+ GitTopic::run
143
+