ionic_git_scripts 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 695d64f8ab639d941d33b1991eae89f8daf2f598
4
+ data.tar.gz: 877c2a86eca3110050408433d70f47c15ed44359
5
+ SHA512:
6
+ metadata.gz: 3ed9f484ff2b13daccef9f0377f4f0c78f374b938c78e09d1cf7312735bd396a3620d86144791ac802f442a82b00c1a684d433e86d315af4cbc9c3daa7da26a0
7
+ data.tar.gz: d29761243d36b1be3d0fbb339d240bd2fdc34903c142bd4808efeb3fca6feef9df50b2a763232e696a5adc02523bc6557e5c105d9f0818dabd1531ce870a2e9b
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
4
+ spec/tmp
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 1.9.2
5
+ - 1.8.7
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in pivotal_git_scripts.gemspec
4
+ gemspec
5
+
6
+ gem "rake"
7
+ gem "bundler"
8
+ gem "rspec"
9
+ gem "unindent"
data/Gemfile.lock ADDED
@@ -0,0 +1,29 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ pivotal_git_scripts (1.1.4)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.1.3)
10
+ rake (0.9.2.2)
11
+ rspec (2.8.0)
12
+ rspec-core (~> 2.8.0)
13
+ rspec-expectations (~> 2.8.0)
14
+ rspec-mocks (~> 2.8.0)
15
+ rspec-core (2.8.0)
16
+ rspec-expectations (2.8.0)
17
+ diff-lcs (~> 1.1.2)
18
+ rspec-mocks (2.8.0)
19
+ unindent (1.0)
20
+
21
+ PLATFORMS
22
+ ruby
23
+
24
+ DEPENDENCIES
25
+ bundler
26
+ pivotal_git_scripts!
27
+ rake
28
+ rspec
29
+ unindent
data/MIT.LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Pivotal Labs
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.md ADDED
@@ -0,0 +1,67 @@
1
+ # Git Scripts
2
+
3
+ These scripts are helpers for managing developer workflow when using git repos hosted on GitHub. Install as a rubygem and they can be run as standard git commands like `git about`.
4
+
5
+ ## Gem Installation
6
+
7
+ $ gem install pivotal_git_scripts
8
+
9
+ ## System Wide Installation
10
+
11
+ $ cd /usr/local/bin && curl -L http://github.com/pivotal/git_scripts/tarball/master | gunzip | tar xvf - --strip=2
12
+
13
+ ## git-about
14
+
15
+ `git about` shows settings set by `git pair` and `git project`
16
+
17
+ ## git-pair
18
+
19
+ Configures git authors when pair programming.
20
+
21
+ git pair sp js
22
+ user.name=Josh Susser & Sam Pierson
23
+ user.email=pair+jsusser+sam@pivotallabs.com
24
+
25
+
26
+ Create a `.pairs` config file in project root or your home folder.
27
+
28
+ # .pairs - configuration for 'git pair'
29
+ pairs:
30
+ # <initials>: <Firstname> <Lastname>[; <email-id>]
31
+ eh: Edward Hieatt
32
+ js: Josh Susser; jsusser
33
+ sf: Serguei Filimonov; serguei
34
+ email:
35
+ prefix: pair
36
+ domain: pivotallabs.com
37
+ # no_solo_prefix: true
38
+ #global: true
39
+
40
+
41
+ By default this affects the current project (.git/config).<br/>
42
+ Use the `--global` option or add `global: true` to your `.pairs` file to set the global git configuration for all projects (~/.gitconfig).
43
+
44
+ Options are:
45
+ -g, --global Modify global git options instead of local
46
+ -v, --version Show Version
47
+ -h, --help Show this.
48
+
49
+ ## git-project
50
+
51
+ $ git project pivots
52
+
53
+ This script sets the user account you will use to access repos hosted on github.com. It creates a symlink from `id_github_current` to `id_github_pivotal<project>`, which switches the SSH key you are currently using to access GitHub repos. Make sure you have the following lines in your .ssh/config file:
54
+
55
+ Host github.com
56
+ User git
57
+ IdentityFile /Users/pivotal/.ssh/id_github_current
58
+
59
+ Authors
60
+ ====
61
+ Copyright (c) 2010 [Pivotal Labs](http://pivotallabs.com). This software is licensed under the MIT License.
62
+
63
+ ### [Contributors](https://github.com/pivotal/git_scripts/contributors)
64
+ - git-pair original author [Bryan Helmkamp](http://brynary.com)
65
+ - lots of pivots :)
66
+ - [James Sanders](https://github.com/jsanders)
67
+ - [Todd Persen](https://github.com/toddboom)
data/Rakefile ADDED
@@ -0,0 +1,22 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ task :default do
4
+ sh "bundle exec rspec spec"
5
+ end
6
+
7
+ # extracted from https://github.com/grosser/project_template
8
+ rule /^version:bump:.*/ do |t|
9
+ sh "git status | grep 'nothing to commit'" # ensure we are not dirty
10
+ index = ['major', 'minor','patch'].index(t.name.split(':').last)
11
+ file = 'lib/pivotal_git_scripts/version.rb'
12
+
13
+ version_file = File.read(file)
14
+ old_version, *version_parts = version_file.match(/(\d+)\.(\d+)\.(\d+)/).to_a
15
+ version_parts[index] = version_parts[index].to_i + 1
16
+ version_parts[2] = 0 if index < 2 # remove patch for minor
17
+ version_parts[1] = 0 if index < 1 # remove minor for major
18
+ new_version = version_parts * '.'
19
+ File.open(file,'w'){|f| f.write(version_file.sub(old_version, new_version)) }
20
+
21
+ sh "bundle && git add #{file} Gemfile.lock && git commit -m 'bump version to #{new_version}'"
22
+ end
data/bin/git-about ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ user_name = `git config --get user.name`
3
+ user_name = "NONE" if user_name.strip.empty?
4
+
5
+ user_email = `git config --get user.email`
6
+ user_email = "NONE" if user_email.strip.empty?
7
+
8
+ begin
9
+ key_file = File.readlink(File.expand_path("~/.ssh/id_github_current"))
10
+ project = (key_file =~ %r{id_github_(\w+)} ? $1 : "NONE")
11
+ rescue Errno::ENOENT
12
+ project = "NONE"
13
+ end
14
+
15
+ puts "git user: #{user_name}"
16
+ puts "git email: #{user_email}"
17
+ puts "GitHub project: #{project}"
data/bin/git-pair ADDED
@@ -0,0 +1,160 @@
1
+ #!/usr/bin/env ruby
2
+ require 'yaml'
3
+ require 'optparse'
4
+
5
+ def parse_cli_options(argv)
6
+ options = {}
7
+ OptionParser.new do |opts|
8
+ # copy-paste from readme
9
+ opts.banner = <<BANNER.sub('<br/>','')
10
+ Configures git authors when pair programming.
11
+
12
+ git pair sp js
13
+ user.name=Josh Susser and Sam Pierson
14
+ user.email=pair+jsusser+sam@pivotallabs.com
15
+
16
+
17
+ Create a `.pairs` config file in project root or your home folder.
18
+
19
+ # .pairs - configuration for 'git pair'
20
+ pairs:
21
+ # <initials>: <Firstname> <Lastname>[; <email-id>]
22
+ eh: Edward Hieatt
23
+ js: Josh Susser; jsusser
24
+ sf: Serguei Filimonov; serguei
25
+ # if email section is present, email will be set
26
+ # if you leave out the email config section, email will not be set
27
+ email:
28
+ prefix: pair
29
+ domain: pivotallabs.com
30
+ # no_solo_prefix: true
31
+ #global: true
32
+
33
+
34
+ By default this affects the current project (.git/config).<br/>
35
+ Use the `--global` option or add `global: true` to your `.pairs` file to set the global git configuration for all projects (~/.gitconfig).
36
+
37
+ Options are:
38
+ BANNER
39
+ opts.on("-g", "--global", "Modify global git options instead of local") { options[:global] = true }
40
+ opts.on("-v", "--version", "Show Version") do
41
+ $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
42
+ require "pivotal_git_scripts/version"
43
+ puts PivotalGitScripts::VERSION
44
+ exit
45
+ end
46
+ opts.on("-h", "--help", "Show this.") { puts opts; exit }
47
+ end.parse!(argv)
48
+
49
+ options
50
+ end
51
+
52
+ def read_pairs_config
53
+ pairs_file_path = nil
54
+ candidate_file_path = '.pairs'
55
+ until pairs_file_path || File.expand_path(candidate_file_path) == '/.pairs' do
56
+ if File.exists?(candidate_file_path)
57
+ pairs_file_path = candidate_file_path
58
+ else
59
+ candidate_file_path = File.join("..", candidate_file_path)
60
+ end
61
+ end
62
+
63
+ unless pairs_file_path
64
+ puts <<-INSTRUCTIONS
65
+ Could not find a .pairs file. Create a YAML file in your project or home directory.
66
+ Format: <initials>: <name>[; <email>]
67
+ Example:
68
+ # .pairs - configuration for 'git pair'
69
+ # place in project or home directory
70
+ pairs:
71
+ eh: Edward Hieatt
72
+ js: Josh Susser; jsusser
73
+ sf: Serguei Filimonov; serguei
74
+ email:
75
+ prefix: pair
76
+ domain: pivotallabs.com
77
+ INSTRUCTIONS
78
+ exit(1)
79
+ end
80
+ pairs_file_path ? YAML.load_file(pairs_file_path) : {}
81
+ end
82
+
83
+ def read_author_info_from_config(config, initials)
84
+ initials.map do |initials|
85
+ if full_name = config['pairs'][initials.downcase]
86
+ full_name
87
+ else
88
+ puts "Couldn't find author name for initials: #{initials}. Add this person to the .pairs file in your project or home directory."
89
+ exit 1
90
+ end
91
+ end
92
+ end
93
+
94
+ def build_email(emails, config)
95
+ if config.is_a?(Hash)
96
+ prefix = config['prefix'] if !config['no_solo_prefix'] or emails.size > 1
97
+ "#{([prefix] + emails).compact.join('+')}@#{config['domain']}"
98
+ else
99
+ config
100
+ end
101
+ end
102
+
103
+ def set_git_config(global_config_string, options)
104
+ options.each do |key,value|
105
+ key = "user.#{key}"
106
+ value = value ? %Q{#{key} "#{value}"} : "--unset #{key}"
107
+ system(%Q{git config#{global_config_string} #{value}})
108
+ end
109
+ system(%x{launchctl stop org.openbsd.ssh-agent})
110
+ system(%x{launchctl start org.openbsd.ssh-agent})
111
+ end
112
+
113
+ def report_git_settings(git_dir, key)
114
+ global = `git config --global --get-regexp '^user\.#{key}'`
115
+ local = `git config -f #{git_dir}/config --get-regexp '^user\.#{key}'`
116
+ if global.length > 0 && local.length > 0
117
+ puts "NOTE: Overriding global user.#{key} setting with local."
118
+ end
119
+ puts "global: #{global}" if global.length > 0
120
+ puts "local: #{local}" if local.length > 0
121
+ end
122
+
123
+ def extract_author_names_and_email_ids_from_config(config, initials)
124
+ authors = read_author_info_from_config(config, initials)
125
+ authors.sort!.uniq!
126
+ authors.map do |a|
127
+ full_name, email_id = a.split(";").map(&:strip)
128
+ email_id ||= full_name.split(' ').first.downcase
129
+ [full_name, email_id]
130
+ end.transpose
131
+ end
132
+
133
+ def no_email(config)
134
+ !config.key? 'email'
135
+ end
136
+
137
+ git_dir = `git rev-parse --git-dir`.chomp
138
+ exit 1 if git_dir.empty?
139
+
140
+ options = parse_cli_options(ARGV)
141
+ initials = ARGV
142
+ config = read_pairs_config
143
+ global = " --global" if options[:global] or config["global"]
144
+
145
+ if initials.any?
146
+ author_names, email_ids = extract_author_names_and_email_ids_from_config(config, initials)
147
+ authors = [author_names[0..-2].join(", "), author_names.last].reject(&:empty?).join(" and ")
148
+ git_config = {:name => authors, :initials => initials.join(" ")}
149
+ git_config[:email] = build_email(email_ids, config["email"]) unless no_email(config)
150
+ set_git_config global, git_config
151
+ else
152
+ git_config = {:name => nil, :initials => nil}
153
+ git_config[:email] = nil unless no_email(config)
154
+ set_git_config global, git_config
155
+ puts "Unset#{global} user.name, #{'user.email, ' unless no_email(config)}user.initials"
156
+ end
157
+
158
+ [:name, :email, :initials].each do |key|
159
+ report_git_settings(git_dir, key)
160
+ end
data/bin/git-project ADDED
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env ruby
2
+ require 'socket'
3
+
4
+ def check_ssh_config
5
+ if `grep -c id_github_current config`.to_i == 0
6
+ puts <<-WARNING
7
+ You must edit your .ssh/config file to include:
8
+ Host github.com
9
+ User git
10
+ IdentityFile /Users/pivotal/.ssh/id_github_current
11
+ WARNING
12
+ end
13
+ end
14
+
15
+ project = ARGV[0] || Dir.pwd.split('/').last
16
+ hostname = Socket.gethostname.split('.').first
17
+ possible_id_files = [
18
+ "id_#{hostname}_github_pivotal#{project}",
19
+ "id_github_pivotal#{project}",
20
+ "id_github_#{project}"
21
+ ]
22
+
23
+ Dir.chdir(File.expand_path('~/.ssh')) do
24
+ possible_id_files.each do |id_file|
25
+ if File.exists?(id_file)
26
+ `ln -sf #{id_file} id_github_current`
27
+ puts "Now using key #{id_file}"
28
+ check_ssh_config
29
+ exit 0
30
+ end
31
+ end
32
+ puts "Key not found. You must create a ssh key in ~/.ssh/ called " +
33
+ possible_id_files[0..-2].join(", ") +
34
+ " or #{possible_id_files[-1]}"
35
+ end
data/bin/git-superpull ADDED
@@ -0,0 +1,2 @@
1
+ #!/bin/sh
2
+ git pull && git submodule init && git submodule update
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $LOAD_PATH.push File.expand_path("../lib", __FILE__)
3
+ require "pivotal_git_scripts/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "ionic_git_scripts"
7
+ s.version = PivotalGitScripts::VERSION
8
+ s.authors = ["Victor Prechtel"]
9
+ s.email = ["vprechtel@asynchrony.com"]
10
+ s.homepage = "http://github.com/ionicmobile/git_script"
11
+ s.summary = %q{Developer git workflow convenience scripts}
12
+ s.description = %q{These scripts are helpers for managing developer workflow when using git repos hosted on GitHub.}
13
+
14
+ s.rubyforge_project = "pivotal_git_scripts"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+ s.license = "MIT"
21
+
22
+ # specify any dependencies here; for example:
23
+ # s.add_development_dependency "rspec"
24
+ # s.add_runtime_dependency "rest-client"
25
+ end
@@ -0,0 +1,3 @@
1
+ module PivotalGitScripts
2
+ VERSION = "1.1.5"
3
+ end
data/spec/cli_spec.rb ADDED
@@ -0,0 +1,266 @@
1
+ require "unindent"
2
+
3
+ describe "CLI" do
4
+ before :all do
5
+ # use local scripts
6
+ ENV["PATH"] = "#{File.join(File.dirname(__FILE__),"..","bin")}:#{ENV["PATH"]}"
7
+ end
8
+
9
+ def run(command, options={})
10
+ result = `#{command}`
11
+ raise "FAILED #{command} : #{result}" if $?.success? == !!options[:fail]
12
+ result
13
+ end
14
+
15
+ def write(file, content)
16
+ File.open(file, 'w'){|f| f.write content }
17
+ end
18
+
19
+ around do |example|
20
+ dir = "spec/tmp"
21
+ run "rm -rf #{dir}"
22
+ run "mkdir #{dir}"
23
+
24
+ # use fake home for .ssh hacks
25
+ run "mkdir #{dir}/home"
26
+ ENV["HOME"] = File.expand_path("#{dir}/home")
27
+
28
+ Dir.chdir dir do
29
+ run "touch a && git init && git add . && git commit -am 'initial'"
30
+ example.run
31
+ end
32
+ end
33
+
34
+ describe "about" do
35
+ it "lists the user" do
36
+ run "git config user.name NAME"
37
+ run("git about").should =~ /git user:\s+NAME/
38
+ end
39
+
40
+ it "lists the user as NONE if there is none" do
41
+ run "git config user.name ''"
42
+ run("git about").should =~ /git user:\s+NONE/
43
+ end
44
+
45
+ it "lists the email" do
46
+ run "git config user.email EMAIL"
47
+ run("git about").should =~ /git email:\s+EMAIL/
48
+ end
49
+
50
+ it "lists the email as NONE if there is none" do
51
+ run "git config user.email ''"
52
+ run("git about").should =~ /git email:\s+NONE/
53
+ end
54
+
55
+ it "does not find a project" do
56
+ run("git about").should =~ /GitHub project:\s+NONE/
57
+ end
58
+
59
+ context "with github project" do
60
+ before do
61
+ run "mkdir home/.ssh"
62
+ run "touch home/.ssh/id_github_foo"
63
+ run "ln -s home/.ssh/id_github_foo home/.ssh/id_github_current"
64
+ end
65
+
66
+ it "finds a project" do
67
+ run("git about").should =~ /GitHub project:\s+foo/
68
+ end
69
+ end
70
+ end
71
+
72
+ describe "pair" do
73
+ def expect_config(result, name, initials, email, options={})
74
+ global = "cd /tmp && " if options[:global]
75
+ run("#{global}git config user.name").should == "#{name}\n"
76
+ run("#{global}git config user.initials").should == "#{initials}\n"
77
+ run("#{global}git config user.email").should == "#{email}\n"
78
+
79
+ prefix = (options[:global] ? "global: " : "local: ")
80
+ result.should include "#{prefix}user.name #{name}"
81
+ result.should include "#{prefix}user.initials #{initials}"
82
+ result.should include "#{prefix}user.email #{email}"
83
+ end
84
+
85
+ def git_config_value(name, global = false)
86
+ global_prefix = "cd /tmp && " if global
87
+ `#{global_prefix}git config user.#{name}`
88
+ end
89
+
90
+ it "prints help" do
91
+ result = run "git-pair --help"
92
+ result.should include("Configures git authors when pair programming")
93
+ end
94
+
95
+ it "prints version" do
96
+ result = run "git pair --version"
97
+ result.should =~ /\d+\.\d+\.\d+/
98
+ end
99
+
100
+ context "with .pairs file" do
101
+ before do
102
+ write ".pairs", <<-YAML.unindent
103
+ pairs:
104
+ ab: Aa Bb
105
+ bc: Bb Cc
106
+ cd: Cc Dd
107
+
108
+ email:
109
+ prefix: the-pair
110
+ domain: the-host.com
111
+ YAML
112
+ end
113
+
114
+ describe "global" do
115
+ it "sets pairs globally when global: true is set" do
116
+ write ".pairs", File.read(".pairs") + "\nglobal: true"
117
+ result = run "git pair ab"
118
+ expect_config result, "Aa Bb", "ab", "the-pair+aa@the-host.com", :global => true
119
+ end
120
+
121
+ it "sets pairs globally when --global is given" do
122
+ result = run "git pair ab --global"
123
+ result.should include "global: user.name Aa Bb"
124
+ expect_config result, "Aa Bb", "ab", "the-pair+aa@the-host.com", :global => true
125
+ end
126
+
127
+ it "unsets global config when no argument is passed" do
128
+ run "git pair ab --global"
129
+ run "git pair ab"
130
+ result = run "git pair --global"
131
+ #result.should include "Unset --global user.name, user.email and user.initials"
132
+ expect_config result, "Aa Bb", "ab", "the-pair+aa@the-host.com"
133
+ result.should_not include("global:")
134
+ end
135
+ end
136
+
137
+ it "can set a single user as pair" do
138
+ result = run "git pair ab"
139
+ expect_config result, "Aa Bb", "ab", "the-pair+aa@the-host.com"
140
+ end
141
+
142
+ it "can set a 2 users as pair" do
143
+ result = run "git pair ab bc"
144
+ expect_config result, "Aa Bb and Bb Cc", "ab bc", "the-pair+aa+bb@the-host.com"
145
+ end
146
+
147
+ it "can set n users as pair" do
148
+ result = run "git pair ab bc cd"
149
+ expect_config result, "Aa Bb, Bb Cc and Cc Dd", "ab bc cd", "the-pair+aa+bb+cc@the-host.com"
150
+ end
151
+
152
+ it "can set a user with apostrophes as pair" do
153
+ write ".pairs", File.read(".pairs").sub("Aa Bb", "Pete O'Connor")
154
+ result = run "git pair ab"
155
+ expect_config result, "Pete O'Connor", "ab", "the-pair+pete@the-host.com"
156
+ end
157
+
158
+ it "fails when there is no .git in the tree" do
159
+ run "rm -f /tmp/pairs"
160
+ run "cp .pairs /tmp"
161
+ Dir.chdir "/tmp" do
162
+ result = run "git pair ab 2>&1", :fail => true
163
+ result.should include("Not a git repository (or any of the parent directories)")
164
+ end
165
+ run "rm -f /tmp/pairs"
166
+ end
167
+
168
+ it "finds .pairs file in lower parent folder" do
169
+ run "mkdir foo"
170
+ Dir.chdir "foo" do
171
+ result = run "git pair ab"
172
+ expect_config result, "Aa Bb", "ab", "the-pair+aa@the-host.com"
173
+ end
174
+ end
175
+
176
+ it "unsets local config when no argument is passed" do
177
+ run "git pair ab --global"
178
+ run "git pair bc"
179
+ result = run "git pair"
180
+ result.should include "Unset user.name, user.email, user.initials"
181
+ expect_config result, "Aa Bb", "ab", "the-pair+aa@the-host.com", :global => true
182
+ result.should_not include("local:")
183
+ end
184
+
185
+ it "uses hard email when given" do
186
+ write ".pairs", File.read(".pairs").sub(/email:.*/m, "email: foo@bar.com")
187
+ result = run "git pair ab"
188
+ expect_config result, "Aa Bb", "ab", "foo@bar.com"
189
+ end
190
+
191
+ context "when no email config is present" do
192
+ before do
193
+ write ".pairs", File.read(".pairs").sub(/email:.*/m, "")
194
+ end
195
+
196
+ it "doesn't set email" do
197
+ run "git pair ab"
198
+ git_config_value('email').should be_empty
199
+ end
200
+
201
+ it "doesn't report about email" do
202
+ result = run "git pair ab"
203
+ result.should_not include "email"
204
+ end
205
+ end
206
+
207
+ it "uses no email prefix when only host is given" do
208
+ write ".pairs", File.read(".pairs").sub(/email:.*/m, "email:\n domain: foo.com")
209
+ result = run "git pair ab"
210
+ expect_config result, "Aa Bb", "ab", "aa@foo.com"
211
+ end
212
+
213
+ context "when no no_solo_prefix is given" do
214
+ before do
215
+ write ".pairs", File.read(".pairs").sub(/email:.*/m, "email:\n prefix: pairs\n no_solo_prefix: true\n domain: foo.com")
216
+ end
217
+
218
+ it "uses no email prefix for single developers" do
219
+ result = run "git pair ab"
220
+ expect_config result, "Aa Bb", "ab", "aa@foo.com"
221
+ end
222
+
223
+ it "uses email prefix for multiple developers" do
224
+ result = run "git pair ab bc"
225
+ expect_config result, "Aa Bb and Bb Cc", "ab bc", "pairs+aa+bb@foo.com"
226
+ end
227
+ end
228
+
229
+ it "fails with unknown initials" do
230
+ result = run "git pair xx", :fail => true
231
+ result.should include("Couldn't find author name for initials: xx")
232
+ end
233
+
234
+ it "uses alternate email prefix" do
235
+ write ".pairs", File.read(".pairs").sub(/ab:.*/, "ab: Aa Bb; blob")
236
+ result = run "git pair ab"
237
+ expect_config result, "Aa Bb", "ab", "the-pair+blob@the-host.com"
238
+ end
239
+ end
240
+
241
+ context "without a .pairs file in the tree" do
242
+ around do |example|
243
+ Dir.chdir "/tmp" do
244
+ run "rm -f .pairs"
245
+ dir = "git_stats_test"
246
+ run "rm -rf #{dir}"
247
+ run "mkdir #{dir}"
248
+ Dir.chdir dir do
249
+ run "git init"
250
+ example.run
251
+ end
252
+ run "rm -rf #{dir}"
253
+ end
254
+ end
255
+
256
+ it "fails if it cannot find a pairs file" do
257
+ run "git pair ab", :fail => true
258
+ end
259
+
260
+ it "prints instructions" do
261
+ result = run "git pair ab", :fail => true
262
+ result.should include("Could not find a .pairs file. Create a YAML file in your project or home directory.")
263
+ end
264
+ end
265
+ end
266
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ionic_git_scripts
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.5
5
+ platform: ruby
6
+ authors:
7
+ - Victor Prechtel
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-03-21 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: These scripts are helpers for managing developer workflow when using
14
+ git repos hosted on GitHub.
15
+ email:
16
+ - vprechtel@asynchrony.com
17
+ executables:
18
+ - git-about
19
+ - git-pair
20
+ - git-project
21
+ - git-superpull
22
+ extensions: []
23
+ extra_rdoc_files: []
24
+ files:
25
+ - .gitignore
26
+ - .rspec
27
+ - .travis.yml
28
+ - Gemfile
29
+ - Gemfile.lock
30
+ - MIT.LICENSE
31
+ - README.md
32
+ - Rakefile
33
+ - bin/git-about
34
+ - bin/git-pair
35
+ - bin/git-project
36
+ - bin/git-superpull
37
+ - ionic_git_scripts.gemspec
38
+ - lib/pivotal_git_scripts/version.rb
39
+ - spec/cli_spec.rb
40
+ homepage: http://github.com/ionicmobile/git_script
41
+ licenses:
42
+ - MIT
43
+ metadata: {}
44
+ post_install_message:
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements: []
59
+ rubyforge_project: pivotal_git_scripts
60
+ rubygems_version: 2.0.0
61
+ signing_key:
62
+ specification_version: 4
63
+ summary: Developer git workflow convenience scripts
64
+ test_files:
65
+ - spec/cli_spec.rb