ec-pairing 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ pkg/*
data/README.markdown ADDED
@@ -0,0 +1,32 @@
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 [--global] abbr 'Person <emailaddress>'`
25
+ * example: `git-pair add --global js 'John Smith <jsmith@example.com>'` # adds pair to ~/.gitconfig
26
+ * example: `git-pair add js 'John Smith <jsmith@example.com>'` # WARNING adds pair to current git repo
27
+ * Show available authors: `git-pair show`
28
+ * Commit with a pair: `git-pair commit [abbr] [git_options]`
29
+
30
+ # Authors
31
+
32
+ * [Ryan Carmelo Briones &lt;ryan.briones@brionesandco.com&gt;](mailto:ryan.briones@brionesandco.com)
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ begin
2
+ require 'jeweler'
3
+ Jeweler::Tasks.new do |gemspec|
4
+ gemspec.name = 'ec-pairing'
5
+ gemspec.summary = 'Simple interface for tying both members of a pair to git commits'
6
+ gemspec.email = 'ryan.briones@brionesandco.com'
7
+ gemspec.homepage = 'http://github.com/edgecase/git-pair'
8
+ gemspec.authors = ['Ryan Briones', 'Jon Distad', 'Adam McCrea']
9
+ end
10
+ rescue LoadError
11
+ puts "Jeweler not available. Install it with: gem install jeweler"
12
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/bin/git-pair ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- ruby -*-
3
+ require 'git-pair/command'
4
+
5
+ exit GitPair::Command.run!(ARGV)
data/git-pair.gemspec ADDED
@@ -0,0 +1,46 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{git-pair}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Ryan Briones", "Jon Distad", "Adam McCrea"]
12
+ s.date = %q{2010-02-17}
13
+ s.default_executable = %q{git-pair}
14
+ s.email = %q{ryan.briones@brionesandco.com}
15
+ s.executables = ["git-pair"]
16
+ s.extra_rdoc_files = [
17
+ "README.markdown"
18
+ ]
19
+ s.files = [
20
+ ".gitignore",
21
+ "README.markdown",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "bin/git-pair",
25
+ "git-pair.gemspec",
26
+ "lib/git-pair/author.rb",
27
+ "lib/git-pair/command.rb",
28
+ "lib/git-pair/commit.rb"
29
+ ]
30
+ s.homepage = %q{http://github.com/edgecase/git-pair}
31
+ s.rdoc_options = ["--charset=UTF-8"]
32
+ s.require_paths = ["lib"]
33
+ s.rubygems_version = %q{1.3.5}
34
+ s.summary = %q{Simple interface for adding your pair to a commit via git commit --author}
35
+
36
+ if s.respond_to? :specification_version then
37
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
38
+ s.specification_version = 3
39
+
40
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
41
+ else
42
+ end
43
+ else
44
+ end
45
+ end
46
+
@@ -0,0 +1,48 @@
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 initialize abbr
31
+ @pair_string = `git config git-pair.authors.#{abbr}`.chomp
32
+ raise "Invalid abbreviation!" if @pair_string.strip.empty?
33
+ end
34
+
35
+ def name
36
+ @pair_string.gsub(/<.*>/, '').strip
37
+ end
38
+
39
+ def email
40
+ @pair_string =~ /<(.*)>/
41
+ $1.to_s.strip
42
+ end
43
+
44
+ def to_s
45
+ @pair_string
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,78 @@
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 = {:passthru => []}
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 [--global] 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
+ committer = @sub_args.shift
32
+ author = @sub_args.shift
33
+ passthru = "#{@options[:passthru].join(' ')} -- #{@sub_args.join(' ')}"
34
+
35
+ return GitPair::Commit.commit(committer, author, passthru)
36
+ else
37
+ puts %Q(Usage: #{$0} show)
38
+ puts %Q(Usage: #{$0} add [--global] js "John Smith <jsmith@example.com>")
39
+ puts %Q(Usage: #{$0} commit <pair 1> <pair 2> [git_options])
40
+ return 0
41
+ end
42
+ end
43
+
44
+ def parse(args)
45
+ OptionParser.new do |opts|
46
+
47
+ opts.on('--global') do |g|
48
+ @options[:global] = g
49
+ end
50
+
51
+ # git commit options
52
+ opts.on('-a', '--all') { |a| @options[:passthru] << "-a"}
53
+ opts.on('-C <commit>', '--reuse-message=<commit>') { |c| @options[:passthru] << "-C #{c}" }
54
+ opts.on('-c <commit>', '--reedit-message=<commit>') { |c| @options[:passthru] << "-c #{c}" }
55
+ opts.on('-F <file>', '--file=<file>') { |f| @options[:passthru] << %Q(-F "#{f}") }
56
+ opts.on('-m <msg>', '--message=<msg>') { |m| @options[:passthru] << %Q(-m "#{m}") }
57
+ opts.on('-t <file>', '--template=<file>') { |t| @options[:passthru] << %Q(-t "#{t}") }
58
+ opts.on('-s', '--signoff') { |s| @options[:passthru] << "-s" }
59
+ opts.on('-n', '--no-verify') { |n| @options[:passthru] << "-n" }
60
+ opts.on('--allow-empty') { |ae| @options[:passthru] << "--allow-empty" }
61
+ opts.on('--cleanup=<mode>') { |cl| @options[:passthru] << "-cleanup=#{cl}" }
62
+ opts.on('-e', '--edit') { |e| @options[:passthru] << "-e" }
63
+ opts.on('--amend') { |am| @options[:passthru] << "--amend" }
64
+ opts.on('-i', '--include') { |i| @options[:passthru] << "-i" }
65
+ opts.on('-o', '--only') { |o| @options[:passthru] << "-o" }
66
+ opts.on('-u[<mode>]', '--untracked-files[=<mode>]') { |u| @options[:passthru] << "-u#{u}" }
67
+ opts.on('-v', '--verbose') { |v| @options[:passthru] << "-v" }
68
+ opts.on('-q', '--quiet') { |q| @options[:passthru] << "-q" }
69
+
70
+ opts.parse!(args)
71
+
72
+ end
73
+
74
+ @sub_command = args.shift
75
+ @sub_args = args
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,19 @@
1
+ require 'git-pair/author'
2
+
3
+ module GitPair
4
+ class Commit
5
+ def self.commit(committer, author, git_args)
6
+ committer = GitPair::Author.new(committer)
7
+ author = GitPair::Author.new(author)
8
+
9
+ command = "GIT_COMMITTER_NAME='#{committer.name}' "
10
+ command << "GIT_COMMITTER_EMAIL='#{committer.email}' "
11
+ command << "git commit "
12
+ command << "--author='#{author}' "
13
+ command << "#{git_args}"
14
+
15
+ system(command)
16
+ $?
17
+ end
18
+ end
19
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ec-pairing
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ryan Briones
8
+ - Jon Distad
9
+ - Adam McCrea
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+
14
+ date: 2010-02-17 00:00:00 -05:00
15
+ default_executable: git-pair
16
+ dependencies: []
17
+
18
+ description:
19
+ email: ryan.briones@brionesandco.com
20
+ executables:
21
+ - git-pair
22
+ extensions: []
23
+
24
+ extra_rdoc_files:
25
+ - README.markdown
26
+ files:
27
+ - .gitignore
28
+ - README.markdown
29
+ - Rakefile
30
+ - VERSION
31
+ - bin/git-pair
32
+ - git-pair.gemspec
33
+ - lib/git-pair/author.rb
34
+ - lib/git-pair/command.rb
35
+ - lib/git-pair/commit.rb
36
+ has_rdoc: true
37
+ homepage: http://github.com/edgecase/git-pair
38
+ licenses: []
39
+
40
+ post_install_message:
41
+ rdoc_options:
42
+ - --charset=UTF-8
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: "0"
50
+ version:
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: "0"
56
+ version:
57
+ requirements: []
58
+
59
+ rubyforge_project:
60
+ rubygems_version: 1.3.5
61
+ signing_key:
62
+ specification_version: 3
63
+ summary: Simple interface for tying both members of a pair to git commits
64
+ test_files: []
65
+