ey_pairing 0.0.1
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/LICENSE +20 -0
- data/README.rdoc +7 -0
- data/bin/ey-pair +3 -0
- data/lib/pairing/cli.rb +27 -0
- data/lib/pairing/commands/base.rb +5 -0
- data/lib/pairing/commands/pre_commit.rb +80 -0
- data/lib/pairing/commands/repo_setup.rb +11 -0
- data/lib/pairing.rb +11 -0
- metadata +80 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Engine Yard, Inc
|
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
data/bin/ey-pair
ADDED
data/lib/pairing/cli.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
class Pairing::Cli
|
2
|
+
def run(argv)
|
3
|
+
name, *remainder = argv
|
4
|
+
|
5
|
+
case name
|
6
|
+
when 'repo-setup'
|
7
|
+
Pairing::Commands::RepoSetup.run(remainder)
|
8
|
+
when 'pre-commit'
|
9
|
+
Pairing::Commands::PreCommit.run(remainder)
|
10
|
+
else
|
11
|
+
usage
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def usage
|
16
|
+
puts <<-TEXT
|
17
|
+
usage: ey-pair COMMAND
|
18
|
+
|
19
|
+
repo-setup Sets up a git repo for use in pairing.
|
20
|
+
TEXT
|
21
|
+
return 1
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.run(argv)
|
25
|
+
new.run(argv)
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
class Pairing::Commands::PreCommit < Pairing::Commands::Base
|
4
|
+
AUTHORS = [
|
5
|
+
{:name => "Andre Arko", :email => 'aarko@engineyard.com'},
|
6
|
+
{:name => "Wesley Beary", :email => 'wbeary@engineyard.com'},
|
7
|
+
{:name => "Jon Crosby", :email => 'jcrosby@engineyard.com'},
|
8
|
+
{:name => "Andy Delcambre", :email => 'adelcambre@engineyard.com'},
|
9
|
+
{:name => "Larry Diehl", :email => 'ldiehl@engineyard.com'},
|
10
|
+
{:name => "Corey Donohoe", :email => 'cdonohoe@engineyard.com'},
|
11
|
+
{:name => "Jared Grippe", :email => 'jgrippe@engineyard.com'},
|
12
|
+
{:name => "Samuel Merritt", :email => 'smerritt@engineyard.com'},
|
13
|
+
{:name => "Martin Emde", :email => 'memde@engineyard.com'},
|
14
|
+
{:name => "Ben Burkert", :email => 'ben@benburkert.com'},
|
15
|
+
{:name => "Simon Rozet", :email => 'srozet@engineyard.com'},
|
16
|
+
{:name => "Tim Carey-Smith", :email => 'tcareysmith@engineyard.com'},
|
17
|
+
]
|
18
|
+
|
19
|
+
AUTHORS.each do |person|
|
20
|
+
person[:init] = person[:name].scan(/(?:^|\s)(\w)/).flatten.join.downcase
|
21
|
+
end
|
22
|
+
|
23
|
+
PAIR_FILE = '.git/ey-pair'
|
24
|
+
|
25
|
+
def run(argv)
|
26
|
+
trap(:INT) { return 1 }
|
27
|
+
|
28
|
+
if user_set_today?
|
29
|
+
existing_user = `git config user.name`.chomp
|
30
|
+
existing_email = `git config user.email`.chomp
|
31
|
+
return if highline.agree("Continue using #{existing_user} <#{existing_email}>?")
|
32
|
+
end
|
33
|
+
|
34
|
+
chosen_user = highline.choose do |menu|
|
35
|
+
menu.prompt = "Which user"
|
36
|
+
menu.index = :none
|
37
|
+
menu.select_by = :name
|
38
|
+
AUTHORS.each do |user|
|
39
|
+
menu.choice("#{user[:init]} (#{user[:name]})") {user}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
pair = highline.choose do |menu|
|
44
|
+
menu.prompt = "Who are you pairing with?"
|
45
|
+
menu.index = :none
|
46
|
+
menu.select_by = :name
|
47
|
+
(AUTHORS + [{:init => "np", :name => "Not Pairing"}]).each do |user|
|
48
|
+
menu.choice("#{user[:init]} (#{user[:name]})") {user}
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
authors = [chosen_user, pair]
|
53
|
+
names = authors.map{|u| u[:name] }.join(" & ")
|
54
|
+
email = chosen_user[:email]
|
55
|
+
|
56
|
+
`git config --replace-all user.name "#{names}"`
|
57
|
+
`git config --replace-all user.email "#{email}"`
|
58
|
+
FileUtils.touch(PAIR_FILE)
|
59
|
+
|
60
|
+
return 0
|
61
|
+
end
|
62
|
+
|
63
|
+
def user_set_today?
|
64
|
+
now = Time.now
|
65
|
+
File.exist?(PAIR_FILE) && (File.mtime(PAIR_FILE) >= Time.mktime(now.year, now.month, now.mday))
|
66
|
+
end
|
67
|
+
|
68
|
+
def highline
|
69
|
+
retried = false
|
70
|
+
@highline ||= begin
|
71
|
+
require 'highline'
|
72
|
+
HighLine.new(File.open('/dev/tty'))
|
73
|
+
rescue LoadError
|
74
|
+
raise if retried
|
75
|
+
require 'rubygems'
|
76
|
+
retried = true
|
77
|
+
retry
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class Pairing::Commands::RepoSetup < Pairing::Commands::Base
|
2
|
+
PRE_COMMIT_FILE = '.git/hooks/pre-commit'
|
3
|
+
|
4
|
+
def run(argv)
|
5
|
+
File.open(PRE_COMMIT_FILE, 'w') do |f|
|
6
|
+
f << %{#!/bin/bash\nexec ey-pair pre-commit}
|
7
|
+
end
|
8
|
+
File.chmod(0700, PRE_COMMIT_FILE)
|
9
|
+
puts "Wrote pre-commit hook to collect pair info"
|
10
|
+
end
|
11
|
+
end
|
data/lib/pairing.rb
ADDED
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ey_pairing
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- EY Cloud Team
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-07-07 00:00:00 -07:00
|
18
|
+
default_executable: ey-pair
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
type: :runtime
|
22
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
segments:
|
27
|
+
- 0
|
28
|
+
version: "0"
|
29
|
+
name: rake
|
30
|
+
prerelease: false
|
31
|
+
requirement: *id001
|
32
|
+
description: Install and use a git hook for pairs at engineyard
|
33
|
+
email: cloud@engineyard.com
|
34
|
+
executables:
|
35
|
+
- ey-pair
|
36
|
+
extensions: []
|
37
|
+
|
38
|
+
extra_rdoc_files: []
|
39
|
+
|
40
|
+
files:
|
41
|
+
- bin/ey-pair
|
42
|
+
- lib/pairing/cli.rb
|
43
|
+
- lib/pairing/commands/base.rb
|
44
|
+
- lib/pairing/commands/pre_commit.rb
|
45
|
+
- lib/pairing/commands/repo_setup.rb
|
46
|
+
- lib/pairing.rb
|
47
|
+
- LICENSE
|
48
|
+
- README.rdoc
|
49
|
+
has_rdoc: true
|
50
|
+
homepage: http://engineyard.com
|
51
|
+
licenses: []
|
52
|
+
|
53
|
+
post_install_message:
|
54
|
+
rdoc_options: []
|
55
|
+
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
version: "0"
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
segments:
|
70
|
+
- 0
|
71
|
+
version: "0"
|
72
|
+
requirements: []
|
73
|
+
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 1.3.6
|
76
|
+
signing_key:
|
77
|
+
specification_version: 3
|
78
|
+
summary: Git hook for pairing
|
79
|
+
test_files: []
|
80
|
+
|