Skip to content
Browse files

map commit options and pass through to git. make readme more clear on…

… usage.
  • Loading branch information...
1 parent 8d1a666 commit 9294cf9e40f714675bf66e670043b33ece2a92cf @ryanbriones committed Nov 3, 2008
Showing with 40 additions and 23 deletions.
  1. +5 −4 README.markdown
  2. +1 −1 Rakefile
  3. +2 −2 git-pair.gemspec
  4. +27 −9 lib/git-pair/command.rb
  5. +5 −7 lib/git-pair/commit.rb
View
9 README.markdown
@@ -21,11 +21,12 @@ I wanted a way for git to show me when a commit was made from a pair during pair
# Usage
-* Add an author: `git-pair add abbr 'Person <emailaddress>'`
- * example: `git-pair add js 'John Smith <jsmith@example.com>'`
+* Add an author: `git-pair add [--global] abbr 'Person <emailaddress>'`
+ * example: `git-pair add --global js 'John Smith <jsmith@example.com>'` # adds pair to ~/.gitconfig
+ * example: `git-pair add js 'John Smith <jsmith@example.com>'` # WARNING adds pair to current git repo
* Show available authors: `git-pair show`
-* Commit with a pair: `git-pair commit [abbr] [-m 'Commit Message']`
+* Commit with a pair: `git-pair commit [abbr] [git_options]`
# Authors
-* [Ryan Carmelo Briones &lt;ryan.briones@brionesandco.com&gt;](mailto:ryan.briones@brionesandco.com)
+* [Ryan Carmelo Briones &lt;ryan.briones@brionesandco.com&gt;](mailto:ryan.briones@brionesandco.com)
View
2 Rakefile
@@ -3,7 +3,7 @@ require 'rake/gempackagetask'
spec = Gem::Specification.new do |s|
s.name = 'git-pair'
- s.version = '0.0.2'
+ s.version = '0.0.3'
s.summary = 'Simple interface for adding your pair to a commit via git commit --author'
s.files = FileList['[A-Z]*', 'bin/*', 'lib/**/*']
s.has_rdoc = false
View
4 git-pair.gemspec
@@ -1,10 +1,10 @@
Gem::Specification.new do |s|
s.name = %q{git-pair}
- s.version = "0.0.2"
+ s.version = "0.0.3"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Ryan Carmelo Briones"]
- s.date = %q{2008-10-28}
+ s.date = %q{2008-11-03}
s.default_executable = %q{git-pair}
s.email = %q{ryan.briones@brionesandco.com}
s.executables = ["git-pair"]
View
36 lib/git-pair/command.rb
@@ -5,7 +5,7 @@
module GitPair
class Command
def initialize
- @options = {}
+ @options = {:passthru => []}
@sub_command = nil
@sub_args = []
end
@@ -22,32 +22,50 @@ def run_sub_command
return GitPair::Author.show
when "add"
unless @sub_args.length == 2
- puts %Q(Usage: #{$0} add js "John Smith <jsmith@example.com>")
+ puts %Q(Usage: #{$0} add [--global] js "John Smith <jsmith@example.com>")
return 1
end
return GitPair::Author.add(@sub_args[0], @sub_args[1], @options)
when "commit"
- return GitPair::Commit.commit(@options[:message], @sub_args[0])
+ pair_abbr = @sub_args.shift
+ passthru = "#{@options[:passthru].join(' ')} -- #{@sub_args.join(' ')}"
+
+ return GitPair::Commit.commit(pair_abbr, passthru)
else
puts %Q(Usage: #{$0} show)
- puts %Q(Usage: #{$0} add js "John Smith <jsmith@example.com>")
- puts %Q(Usage: #{$0} commit [pair] [-m <msg>] )
+ puts %Q(Usage: #{$0} add [--global] js "John Smith <jsmith@example.com>")
+ puts %Q(Usage: #{$0} commit [pair] [git_options])
return 0
end
end
def parse(args)
OptionParser.new do |opts|
- opts.on('-m <msg>') do |m|
- @options[:message] = m
- end
-
opts.on('--global') do |g|
@options[:global] = g
end
+ # git commit options
+ opts.on('-a', '--all') { |a| @options[:passthru] << "-a"}
+ opts.on('-C <commit>', '--reuse-message=<commit>') { |c| @options[:passthru] << "-C #{c}" }
+ opts.on('-c <commit>', '--reedit-message=<commit>') { |c| @options[:passthru] << "-c #{c}" }
+ opts.on('-F <file>', '--file=<file>') { |f| @options[:passthru] << %Q(-F "#{f}") }
+ opts.on('-m <msg>', '--message=<msg>') { |m| @options[:passthru] << %Q(-m "#{m}") }
+ opts.on('-t <file>', '--template=<file>') { |t| @options[:passthru] << %Q(-t "#{t}") }
+ opts.on('-s', '--signoff') { |s| @options[:passthru] << "-s" }
+ opts.on('-n', '--no-verify') { |n| @options[:passthru] << "-n" }
+ opts.on('--allow-empty') { |ae| @options[:passthru] << "--allow-empty" }
+ opts.on('--cleanup=<mode>') { |cl| @options[:passthru] << "-cleanup=#{cl}" }
+ opts.on('-e', '--edit') { |e| @options[:passthru] << "-e" }
+ opts.on('--amend') { |am| @options[:passthru] << "--amend" }
+ opts.on('-i', '--include') { |i| @options[:passthru] << "-i" }
+ opts.on('-o', '--only') { |o| @options[:passthru] << "-o" }
+ opts.on('-u[<mode>]', '--untracked-files[=<mode>]') { |u| @options[:passthru] << "-u#{u}" }
+ opts.on('-v', '--verbose') { |v| @options[:passthru] << "-v" }
+ opts.on('-q', '--quiet') { |q| @options[:passthru] << "-q" }
+
opts.parse!(args)
end
View
12 lib/git-pair/commit.rb
@@ -2,16 +2,14 @@
module GitPair
class Commit
- def self.commit(message, pair_abbr)
- base_command = "git commit"
+ def self.commit(pair_abbr, git_args)
+ command = "git commit"
author = GitPair::Author.find_by_abbr(pair_abbr)
-
- args = []
- args << %Q(-m "#{message}") unless message.nil? || message.empty?
- args << %Q(--author="#{author}") if author
- command = "#{base_command} #{args.join(' ')}"
+ command << %Q( --author="#{author}") if author
+ command << " #{git_args}" if git_args && git_args != ""
+
system(command)
return $?
end

0 comments on commit 9294cf9

Please sign in to comment.
Something went wrong with that request. Please try again.