ryanbriones-git-pair 0.0.2
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/README.markdown +31 -0
- data/Rakefile +26 -0
- data/bin/git-pair +5 -0
- data/lib/git-pair/author.rb +35 -0
- data/lib/git-pair/command.rb +59 -0
- data/lib/git-pair/commit.rb +19 -0
- metadata +59 -0
data/README.markdown
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# git-pair
|
2
|
+
|
3
|
+
* Code: [http://github.com/ryanbriones/git-pair](http://github.com/ryanbriones/git-pair)
|
4
|
+
|
5
|
+
# Description
|
6
|
+
|
7
|
+
I wanted a way for git to show me when a commit was made from a pair during pair programming. As usual, git provides a mechanism for the concept using the --author option on git commit. Inspired by [Bryan Helpkamp's git pairing script] [1] I wanted git-pair to have a list of authors that was loaded from outside the script. Git, being amazingly flexible, allowed me to store information about authors in the git config and access the information uniformly. And so it is.
|
8
|
+
|
9
|
+
[1]: http://www.brynary.com/2008/9/1/setting-the-git-commit-author-to-pair-programmers-names
|
10
|
+
|
11
|
+
# Install
|
12
|
+
|
13
|
+
## Using GitHub's gem repo
|
14
|
+
sudo gem install ryanbriones-git-pair --source=http://gems.github.com
|
15
|
+
|
16
|
+
## From source
|
17
|
+
git clone git://github.com/ryanbriones/git-pair.git
|
18
|
+
cd git-pair
|
19
|
+
rake
|
20
|
+
sudo gem install --local pkg/git-pair-X.X.X.gem
|
21
|
+
|
22
|
+
# Usage
|
23
|
+
|
24
|
+
* Add an author: `git-pair add abbr 'Person <emailaddress>'`
|
25
|
+
* example: `git-pair add js 'John Smith <jsmith@example.com>'`
|
26
|
+
* Show available authors: `git-pair show`
|
27
|
+
* Commit with a pair: `git-pair commit [abbr] [-m 'Commit Message']`
|
28
|
+
|
29
|
+
# Authors
|
30
|
+
|
31
|
+
* [Ryan Carmelo Briones <ryan.briones@brionesandco.com>](mailto:ryan.briones@brionesandco.com)
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
|
4
|
+
spec = Gem::Specification.new do |s|
|
5
|
+
s.name = 'git-pair'
|
6
|
+
s.version = '0.0.2'
|
7
|
+
s.summary = 'Simple interface for adding your pair to a commit via git commit --author'
|
8
|
+
s.files = FileList['[A-Z]*', 'bin/*', 'lib/**/*']
|
9
|
+
s.has_rdoc = false
|
10
|
+
s.bindir = 'bin'
|
11
|
+
s.executables = ['git-pair']
|
12
|
+
s.default_executable = 'git-pair'
|
13
|
+
s.author = 'Ryan Carmelo Briones'
|
14
|
+
s.email = 'ryan.briones@brionesandco.com'
|
15
|
+
s.homepage = 'http://brionesandco.com/ryanbriones'
|
16
|
+
end
|
17
|
+
|
18
|
+
package_task = Rake::GemPackageTask.new(spec) {}
|
19
|
+
|
20
|
+
task :build_gemspec do
|
21
|
+
File.open("#{spec.name}.gemspec", "w") do |f|
|
22
|
+
f.write spec.to_ruby
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
task :default => [:build_gemspec, :gem]
|
data/bin/git-pair
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
module GitPair
|
2
|
+
class Author
|
3
|
+
def self.add(abbr, email, options = {})
|
4
|
+
base_command = "git config"
|
5
|
+
|
6
|
+
args = []
|
7
|
+
args << "--global" if options[:global]
|
8
|
+
args << "git-pair.authors.#{abbr}"
|
9
|
+
args << %Q("#{email}")
|
10
|
+
|
11
|
+
command = "#{base_command} #{args.join(' ')}"
|
12
|
+
system(command)
|
13
|
+
return $?
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.show
|
17
|
+
author_regex = /^git-pair.authors.([^=]+)=(.+)$/
|
18
|
+
authors = `git config --list | grep 'git-pair.authors'`
|
19
|
+
|
20
|
+
puts "Authors"
|
21
|
+
puts "========"
|
22
|
+
|
23
|
+
authors.each_line do |line|
|
24
|
+
line =~ author_regex
|
25
|
+
puts "#{$1} - #{$2}"
|
26
|
+
end
|
27
|
+
return 0
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.find_by_abbr(pair_abbr)
|
31
|
+
pair = `git config git-pair.authors.#{pair_abbr}`.chomp
|
32
|
+
return pair unless pair.empty?
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'git-pair/author'
|
3
|
+
require 'git-pair/commit'
|
4
|
+
|
5
|
+
module GitPair
|
6
|
+
class Command
|
7
|
+
def initialize
|
8
|
+
@options = {}
|
9
|
+
@sub_command = nil
|
10
|
+
@sub_args = []
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.run!(argv)
|
14
|
+
command = self.new
|
15
|
+
command.parse(argv)
|
16
|
+
command.run_sub_command
|
17
|
+
end
|
18
|
+
|
19
|
+
def run_sub_command
|
20
|
+
case @sub_command
|
21
|
+
when "show"
|
22
|
+
return GitPair::Author.show
|
23
|
+
when "add"
|
24
|
+
unless @sub_args.length == 2
|
25
|
+
puts %Q(Usage: #{$0} add js "John Smith <jsmith@example.com>")
|
26
|
+
return 1
|
27
|
+
end
|
28
|
+
|
29
|
+
return GitPair::Author.add(@sub_args[0], @sub_args[1], @options)
|
30
|
+
when "commit"
|
31
|
+
return GitPair::Commit.commit(@options[:message], @sub_args[0])
|
32
|
+
else
|
33
|
+
puts %Q(Usage: #{$0} show)
|
34
|
+
puts %Q(Usage: #{$0} add js "John Smith <jsmith@example.com>")
|
35
|
+
puts %Q(Usage: #{$0} commit [pair] [-m <msg>] )
|
36
|
+
return 0
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def parse(args)
|
41
|
+
OptionParser.new do |opts|
|
42
|
+
|
43
|
+
opts.on('-m <msg>') do |m|
|
44
|
+
@options[:message] = m
|
45
|
+
end
|
46
|
+
|
47
|
+
opts.on('--global') do |g|
|
48
|
+
@options[:global] = g
|
49
|
+
end
|
50
|
+
|
51
|
+
opts.parse!(args)
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
@sub_command = args.shift
|
56
|
+
@sub_args = args
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'git-pair/author'
|
2
|
+
|
3
|
+
module GitPair
|
4
|
+
class Commit
|
5
|
+
def self.commit(message, pair_abbr)
|
6
|
+
base_command = "git commit"
|
7
|
+
|
8
|
+
author = GitPair::Author.find_by_abbr(pair_abbr)
|
9
|
+
|
10
|
+
args = []
|
11
|
+
args << %Q(-m "#{message}") unless message.nil? || message.empty?
|
12
|
+
args << %Q(--author="#{author}") if author
|
13
|
+
|
14
|
+
command = "#{base_command} #{args.join(' ')}"
|
15
|
+
system(command)
|
16
|
+
return $?
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ryanbriones-git-pair
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryan Carmelo Briones
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-10-28 00:00:00 -07:00
|
13
|
+
default_executable: git-pair
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email: ryan.briones@brionesandco.com
|
18
|
+
executables:
|
19
|
+
- git-pair
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- Rakefile
|
26
|
+
- README.markdown
|
27
|
+
- bin/git-pair
|
28
|
+
- lib/git-pair
|
29
|
+
- lib/git-pair/author.rb
|
30
|
+
- lib/git-pair/command.rb
|
31
|
+
- lib/git-pair/commit.rb
|
32
|
+
has_rdoc: false
|
33
|
+
homepage: http://brionesandco.com/ryanbriones
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options: []
|
36
|
+
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: "0"
|
50
|
+
version:
|
51
|
+
requirements: []
|
52
|
+
|
53
|
+
rubyforge_project:
|
54
|
+
rubygems_version: 1.2.0
|
55
|
+
signing_key:
|
56
|
+
specification_version: 2
|
57
|
+
summary: Simple interface for adding your pair to a commit via git commit --author
|
58
|
+
test_files: []
|
59
|
+
|