capita_git 0.1.4 → 0.1.5
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/Gemfile.lock +1 -3
- data/capita_git.gemspec +1 -1
- data/lib/capita_git/cli.rb +10 -0
- data/lib/capita_git/version.rb +1 -1
- data/man/gitc-install_autocomplete.ronn +1 -1
- data/man/gitc.ronn +5 -0
- data/test/cli_test.rb +4 -0
- data/test/shoulda_macros.rb +30 -23
- metadata +6 -6
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
capita_git (0.1.
|
4
|
+
capita_git (0.1.4)
|
5
5
|
git (>= 1.2.5)
|
6
6
|
thor (>= 0.14.6)
|
7
7
|
|
@@ -25,8 +25,6 @@ PLATFORMS
|
|
25
25
|
|
26
26
|
DEPENDENCIES
|
27
27
|
capita_git!
|
28
|
-
git (>= 1.2.5)
|
29
28
|
open4
|
30
29
|
ronn (>= 0.7.3)
|
31
30
|
shoulda (>= 2.11.0)
|
32
|
-
thor (>= 0.14.6)
|
data/capita_git.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.homepage = "https://github.com/capita/capita_git"
|
12
12
|
s.summary = %q{Git-automation tool for quick handling of common patterns for feature and fix branches}
|
13
13
|
s.description = %q{Git-automation tool for quick handling of common patterns for feature and fix branches}
|
14
|
-
|
14
|
+
s.post_install_message = %Q{Installed/Updated *gitc*, please issue *gitc install_autocomplete* to install/update bash-completion}
|
15
15
|
s.rubyforge_project = "capita_git"
|
16
16
|
|
17
17
|
man_files = Dir.glob("lib/capita_git/man/**/*")
|
data/lib/capita_git/cli.rb
CHANGED
@@ -8,6 +8,16 @@ module CapitaGit
|
|
8
8
|
class CLI < Thor
|
9
9
|
include Thor::Actions
|
10
10
|
|
11
|
+
['checkout', 'push', 'pull', 'fetch', 'add', 'rm', 'status', 'diff', 'commit', 'rebase'].each do |cmd|
|
12
|
+
class_eval do
|
13
|
+
desc "#{cmd}", "Passes #{cmd} to git"
|
14
|
+
define_method cmd.to_sym do |*args|
|
15
|
+
log :warn, 'You called a git command from gitc, passing it along for now...'
|
16
|
+
system "git #{cmd} #{args}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
11
21
|
def initialize(*)
|
12
22
|
super
|
13
23
|
the_shell = (options["no-color"] ? Thor::Shell::Basic.new : shell)
|
data/lib/capita_git/version.rb
CHANGED
@@ -7,4 +7,4 @@ gitc-install_autocomplete(1) -- Installs gitc autocompletion
|
|
7
7
|
|
8
8
|
## DESCRIPTION
|
9
9
|
|
10
|
-
**gitc
|
10
|
+
**gitc install_autocomplete** installs a script in ~/.gitc_autocompletion, appends inclusion in ~/.bashrc and sources into current shell.
|
data/man/gitc.ronn
CHANGED
@@ -53,3 +53,8 @@ Available commands currently are:
|
|
53
53
|
|
54
54
|
* <install_autocomplete>:
|
55
55
|
installs/updates and loads gitc autocompletion bash extension
|
56
|
+
|
57
|
+
## GIT-PASSTHROUGH
|
58
|
+
|
59
|
+
If **gitc** is called with a default git-command it will pass on both command and arguments to git after displaying
|
60
|
+
a short warning
|
data/test/cli_test.rb
CHANGED
@@ -5,6 +5,10 @@ class CliTest < Test::Unit::TestCase
|
|
5
5
|
in_dir 'local_checkout_1' do
|
6
6
|
after('git pull') { should_have_tag '1.0' }
|
7
7
|
|
8
|
+
should('respond to git-cmd #status') { assert_command_match 'gitc status', "nothing to commit" }
|
9
|
+
should('respond to git-cmd #pull') { assert_command_match 'gitc pull', "Already up-to-date" }
|
10
|
+
should('respond to git-cmd #push') { assert_command_match 'gitc push', "Everything up-to-date" }
|
11
|
+
|
8
12
|
gitc 'check' do
|
9
13
|
should_have_branch '1.0-fix'
|
10
14
|
|
data/test/shoulda_macros.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module ShouldaMacros
|
2
2
|
TEMP_DIR = File.expand_path('/tmp/capita_git_tmp')
|
3
3
|
BIN_PATH = File.expand_path(File.join(File.dirname(__FILE__), '..', 'bin/gitc'))
|
4
|
-
|
4
|
+
|
5
5
|
# Test method level helpers
|
6
6
|
module InstanceMethods
|
7
7
|
# Returns the path to the temporary directory, with the optional subdirectory
|
@@ -20,21 +20,28 @@ module ShouldaMacros
|
|
20
20
|
yield
|
21
21
|
end
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
# Runs the specified command and asserts it's exit status should be 0
|
25
25
|
def assert_command(cmd)
|
26
|
-
Open4.popen4(cmd) { |pid, stdin, stdout, stderr|
|
26
|
+
Open4.popen4(cmd) { |pid, stdin, stdout, stderr|}
|
27
27
|
#puts `#{cmd}`
|
28
28
|
assert_equal 0, $?.exitstatus, "Expected exit status of 0 for command '#{cmd}'"
|
29
29
|
end
|
30
30
|
|
31
|
+
# Runs the specified command and asserts it's output matches given string
|
32
|
+
def assert_command_match(cmd, match)
|
33
|
+
pid, stdin, stdout, stderr = Open4.popen4(cmd)
|
34
|
+
stdin.close
|
35
|
+
assert stdout.read.match Regexp.new(match)
|
36
|
+
end
|
37
|
+
|
31
38
|
# Runs the specified command and asserts it's exit status should be 1
|
32
39
|
def assert_command_fail(cmd)
|
33
|
-
Open4.popen4(cmd) { |pid, stdin, stdout, stderr|
|
40
|
+
Open4.popen4(cmd) { |pid, stdin, stdout, stderr|}
|
34
41
|
#puts `#{cmd}`
|
35
42
|
assert_equal 1, $?.exitstatus, "Expected exit status of 1 for command '#{cmd}'"
|
36
43
|
end
|
37
|
-
|
44
|
+
|
38
45
|
# Opens a Git ruby lib instance for current working dir and returns it
|
39
46
|
def repo
|
40
47
|
Git.open(Dir.getwd)
|
@@ -43,7 +50,7 @@ module ShouldaMacros
|
|
43
50
|
|
44
51
|
# Context and should block helpers
|
45
52
|
module ClassMethods
|
46
|
-
|
53
|
+
|
47
54
|
#
|
48
55
|
# Creates a repository with a remote in temp_dir
|
49
56
|
#
|
@@ -53,11 +60,11 @@ module ShouldaMacros
|
|
53
60
|
ENV["GIT_WORK_TREE"] = nil
|
54
61
|
ENV['GIT_DIR'] = nil
|
55
62
|
ENV['GIT_INDEX_FILE'] = nil
|
56
|
-
|
63
|
+
|
57
64
|
in_dir 'origin' do
|
58
65
|
assert_command 'git init --bare'
|
59
66
|
end
|
60
|
-
|
67
|
+
|
61
68
|
in_dir "initial_commit" do
|
62
69
|
assert_command 'git init'
|
63
70
|
assert_command "echo 'foo bar commit' > README"
|
@@ -65,13 +72,13 @@ module ShouldaMacros
|
|
65
72
|
assert_command "git remote add origin #{temp_dir('origin')}"
|
66
73
|
assert_command 'git push origin master'
|
67
74
|
end
|
68
|
-
|
75
|
+
|
69
76
|
in_dir "local_checkout_1" do
|
70
77
|
assert_command "git clone #{temp_dir('origin')} ."
|
71
78
|
assert_command 'git push origin master'
|
72
79
|
assert_command 'git pull origin master'
|
73
80
|
end
|
74
|
-
|
81
|
+
|
75
82
|
in_dir "local_checkout_2" do
|
76
83
|
assert_command "git clone #{temp_dir('origin')} ."
|
77
84
|
assert_command 'git tag -a 1.0 -m "First release"'
|
@@ -79,16 +86,16 @@ module ShouldaMacros
|
|
79
86
|
assert_command 'git pull origin master'
|
80
87
|
end
|
81
88
|
end
|
82
|
-
|
89
|
+
|
83
90
|
yield
|
84
|
-
|
91
|
+
|
85
92
|
# Make sure the temporary directory is purged after every run
|
86
93
|
teardown do
|
87
94
|
FileUtils.rm_rf(temp_dir)
|
88
95
|
end
|
89
96
|
end
|
90
97
|
end
|
91
|
-
|
98
|
+
|
92
99
|
def in_dir(name)
|
93
100
|
context "in dir '#{name}'" do
|
94
101
|
setup do
|
@@ -96,15 +103,15 @@ module ShouldaMacros
|
|
96
103
|
@original_wd[name] = Dir.getwd
|
97
104
|
Dir.chdir(temp_dir(name))
|
98
105
|
end
|
99
|
-
|
106
|
+
|
100
107
|
yield
|
101
|
-
|
108
|
+
|
102
109
|
teardown do
|
103
110
|
Dir.chdir(@original_wd[name]) if @original_wd
|
104
111
|
end
|
105
112
|
end
|
106
113
|
end
|
107
|
-
|
114
|
+
|
108
115
|
# Invokes the gitc binary with given arguments and yields after the setup
|
109
116
|
def gitc(args)
|
110
117
|
context "after invoking 'gitc #{args}'" do
|
@@ -112,7 +119,7 @@ module ShouldaMacros
|
|
112
119
|
yield
|
113
120
|
end
|
114
121
|
end
|
115
|
-
|
122
|
+
|
116
123
|
def after(command)
|
117
124
|
context "after '#{command}'" do
|
118
125
|
setup do
|
@@ -121,31 +128,31 @@ module ShouldaMacros
|
|
121
128
|
yield
|
122
129
|
end
|
123
130
|
end
|
124
|
-
|
131
|
+
|
125
132
|
def should_have_branch(name)
|
126
133
|
should "have branch '#{name}'" do
|
127
134
|
assert repo.branches.map(&:name).include?(name), "Found in #{Dir.getwd}: " + repo.branches.map(&:name).inspect
|
128
135
|
end
|
129
136
|
end
|
130
|
-
|
137
|
+
|
131
138
|
def should_not_have_branch(name)
|
132
139
|
should "NOT have branch '#{name}'" do
|
133
140
|
assert !repo.branches.map(&:name).include?(name), "Found in #{Dir.getwd}: " + repo.branches.map(&:name).inspect
|
134
141
|
end
|
135
142
|
end
|
136
|
-
|
143
|
+
|
137
144
|
def should_have_tag(name)
|
138
145
|
should "have tag '#{name}'" do
|
139
146
|
assert repo.tags.map(&:name).include?(name), repo.tags.map(&:name).inspect
|
140
147
|
end
|
141
148
|
end
|
142
|
-
|
149
|
+
|
143
150
|
def should_not_have_tag(name)
|
144
151
|
should "NOT have tag '#{name}'" do
|
145
152
|
assert !repo.tags.map(&:name).include?(name), repo.tags.map(&:name).inspect
|
146
153
|
end
|
147
154
|
end
|
148
|
-
|
155
|
+
|
149
156
|
def should_have_file(name, options)
|
150
157
|
raise "Usage: should_have_file 'filename', :in => 'tempdirname' (or %w(dir1 dir2))" unless options[:in]
|
151
158
|
[options[:in]].flatten.each do |dir|
|
@@ -154,7 +161,7 @@ module ShouldaMacros
|
|
154
161
|
end
|
155
162
|
end
|
156
163
|
end
|
157
|
-
|
164
|
+
|
158
165
|
def should_not_have_file(name, options)
|
159
166
|
raise "Usage: should_not_have_file 'filename', :in => 'tempdirname' (or %w(dir1 dir2))" unless options[:in]
|
160
167
|
[options[:in]].flatten.each do |dir|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capita_git
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 5
|
10
|
+
version: 0.1.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sebastian Georgi
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-02-
|
19
|
+
date: 2011-02-07 00:00:00 +01:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -149,7 +149,7 @@ has_rdoc: true
|
|
149
149
|
homepage: https://github.com/capita/capita_git
|
150
150
|
licenses: []
|
151
151
|
|
152
|
-
post_install_message:
|
152
|
+
post_install_message: Installed/Updated *gitc*, please issue *gitc install_autocomplete* to install/update bash-completion
|
153
153
|
rdoc_options: []
|
154
154
|
|
155
155
|
require_paths:
|
@@ -175,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
175
|
requirements: []
|
176
176
|
|
177
177
|
rubyforge_project: capita_git
|
178
|
-
rubygems_version: 1.
|
178
|
+
rubygems_version: 1.5.0
|
179
179
|
signing_key:
|
180
180
|
specification_version: 3
|
181
181
|
summary: Git-automation tool for quick handling of common patterns for feature and fix branches
|