git-smart 0.1.8 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +3 -2
- data/Gemfile.lock +11 -3
- data/VERSION +1 -1
- data/lib/git-smart/git_repo.rb +33 -4
- data/spec/smart-merge_failures_spec.rb +3 -0
- data/spec/smart-merge_spec.rb +6 -3
- data/spec/smart-pull_spec.rb +57 -4
- data/spec/spec_helper.rb +1 -0
- metadata +43 -37
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 64ad55375b56d448e73868a6f94752cfdff26dc5ab5fda21c36e4ee25e7388cf
|
4
|
+
data.tar.gz: 795a52c8fc520bbc3c37cdc5b66b36a2482f9820f19e1da6cdebd8365a1531bd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c5c6c4acd4930017ea59a695a457232f62fc18807adbf6f93ec65f73289cb9377cbd8fb9a00758ce78e44ee76b29cf979451db27c21313ead3a6f21d7806a331
|
7
|
+
data.tar.gz: 9644dcbaaa3e69c34f53d42c87b21cf8aacd29ec7b6d8241694882dcdbcd0c1e1670a0b40354c70cc7d4b3f467a312349295fa85c7ea235344cfceeabbfd915e
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
GEM
|
2
|
-
remote:
|
2
|
+
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
4
|
colorize (0.5.8)
|
5
5
|
diff-lcs (1.1.3)
|
6
|
+
docile (1.1.1)
|
7
|
+
multi_json (1.8.2)
|
6
8
|
mustache (0.99.4)
|
7
|
-
|
9
|
+
rake (10.0.3)
|
8
10
|
redcarpet (1.17.2)
|
9
11
|
rocco (0.8.2)
|
10
12
|
mustache
|
@@ -17,12 +19,18 @@ GEM
|
|
17
19
|
rspec-expectations (2.7.0)
|
18
20
|
diff-lcs (~> 1.1.2)
|
19
21
|
rspec-mocks (2.7.0)
|
22
|
+
simplecov (0.8.2)
|
23
|
+
docile (~> 1.1.0)
|
24
|
+
multi_json
|
25
|
+
simplecov-html (~> 0.8.0)
|
26
|
+
simplecov-html (0.8.0)
|
20
27
|
|
21
28
|
PLATFORMS
|
22
29
|
ruby
|
23
30
|
|
24
31
|
DEPENDENCIES
|
25
32
|
colorize
|
26
|
-
|
33
|
+
rake
|
27
34
|
rocco
|
28
35
|
rspec
|
36
|
+
simplecov
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.11
|
data/lib/git-smart/git_repo.rb
CHANGED
@@ -1,13 +1,41 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
require 'pathname'
|
5
|
+
|
1
6
|
class GitRepo
|
2
7
|
def initialize(dir)
|
3
8
|
@dir = dir
|
4
|
-
|
5
|
-
raise GitSmart::RunFailed.new(
|
9
|
+
unless File.directory?(git_dir)
|
10
|
+
raise GitSmart::RunFailed.new(
|
11
|
+
<<-MSG.gsub(/^\s+/, '')
|
12
|
+
You need to run this from within a Git directory.
|
13
|
+
Current working directory: #{File.expand_path(dir)}
|
14
|
+
Expected .git directory: #{git_dir}
|
15
|
+
MSG
|
16
|
+
)
|
6
17
|
end
|
7
18
|
end
|
8
19
|
|
20
|
+
def git_dir
|
21
|
+
gitdir = Pathname.new(@dir).join('.git')
|
22
|
+
|
23
|
+
unless File.exists?(gitdir)
|
24
|
+
@dir = git('rev-parse', '--show-toplevel').chomp
|
25
|
+
gitdir = Pathname.new(@dir).join('.git') unless @dir.empty?
|
26
|
+
end
|
27
|
+
|
28
|
+
if File.file?(gitdir)
|
29
|
+
submodule = YAML.load_file(gitdir)
|
30
|
+
gitdir = Pathname.new(@dir).join(submodule['gitdir']).to_path
|
31
|
+
end
|
32
|
+
|
33
|
+
gitdir
|
34
|
+
end
|
35
|
+
|
9
36
|
def current_branch
|
10
|
-
File.
|
37
|
+
head_file = File.join(git_dir, 'HEAD')
|
38
|
+
File.read(head_file).strip.sub(%r(^.*refs/heads/), '')
|
11
39
|
end
|
12
40
|
|
13
41
|
def sha(ref)
|
@@ -87,7 +115,7 @@ class GitRepo
|
|
87
115
|
end
|
88
116
|
|
89
117
|
def rebase_preserving_merges!(upstream)
|
90
|
-
git!('rebase', '-
|
118
|
+
git!('rebase', '--rebase-merges', upstream)
|
91
119
|
end
|
92
120
|
|
93
121
|
def read_log(nr)
|
@@ -136,6 +164,7 @@ class GitRepo
|
|
136
164
|
private
|
137
165
|
|
138
166
|
def exec_git(*args)
|
167
|
+
return if @dir.empty?
|
139
168
|
Dir.chdir(@dir) {
|
140
169
|
SafeShell.execute('git', *args)
|
141
170
|
}
|
@@ -11,6 +11,9 @@ describe 'smart-merge with failures' do
|
|
11
11
|
mkdir local
|
12
12
|
cd local
|
13
13
|
git init
|
14
|
+
git config --local user.name 'Maxwell Smart'
|
15
|
+
git config --local user.email 'agent86@control.gov'
|
16
|
+
git config --local core.pager 'cat'
|
14
17
|
echo -e 'one\ntwo\nthree\nfour\n' > README
|
15
18
|
mkdir lib
|
16
19
|
echo 'puts "pro hax"' > lib/codes.rb
|
data/spec/smart-merge_spec.rb
CHANGED
@@ -11,6 +11,9 @@ describe 'smart-merge' do
|
|
11
11
|
mkdir local
|
12
12
|
cd local
|
13
13
|
git init
|
14
|
+
git config --local user.name 'Maxwell Smart'
|
15
|
+
git config --local user.email 'agent86@control.gov'
|
16
|
+
git config --local core.pager 'cat'
|
14
17
|
echo 'hurr durr' > README
|
15
18
|
mkdir lib
|
16
19
|
echo 'puts "pro hax"' > lib/codes.rb
|
@@ -58,7 +61,7 @@ describe 'smart-merge' do
|
|
58
61
|
out.should report("Branch 'newbranch' has diverged by 1 commit. Merging in.")
|
59
62
|
out.should report("* Branch 'master' has not moved on since 'newbranch' diverged. Running with --no-ff anyway, since a fast-forward is unexpected behaviour.")
|
60
63
|
out.should report("Executing: git merge --no-ff newbranch")
|
61
|
-
out.should report(
|
64
|
+
out.should report(/2 files changed, 2 insertions\(\+\)(, 0 deletions\(-\))?$/)
|
62
65
|
out.should report(/All good\. Created merge commit [\w]{7}\./)
|
63
66
|
end
|
64
67
|
|
@@ -77,7 +80,7 @@ describe 'smart-merge' do
|
|
77
80
|
out.should report("Branch 'newbranch' has diverged by 1 commit. Merging in.")
|
78
81
|
out.should report("Branch 'master' has 1 new commit since 'newbranch' diverged.")
|
79
82
|
out.should report("Executing: git merge --no-ff newbranch")
|
80
|
-
out.should report(
|
83
|
+
out.should report(/2 files changed, 2 insertions\(\+\)(, 0 deletions\(-\))?$/)
|
81
84
|
out.should report(/All good\. Created merge commit [\w]{7}\./)
|
82
85
|
end
|
83
86
|
|
@@ -91,7 +94,7 @@ describe 'smart-merge' do
|
|
91
94
|
out = run_command(local_dir, 'smart-merge', 'newbranch')
|
92
95
|
out.should report("Executing: git stash")
|
93
96
|
out.should report("Executing: git merge --no-ff newbranch")
|
94
|
-
out.should report(
|
97
|
+
out.should report(/2 files changed, 2 insertions\(\+\)(, 0 deletions\(-\))?$/)
|
95
98
|
out.should report("Reapplying local changes...")
|
96
99
|
out.should report("Executing: git stash pop")
|
97
100
|
out.should report(/All good\. Created merge commit [\w]{7}\./)
|
data/spec/smart-pull_spec.rb
CHANGED
@@ -12,14 +12,20 @@ describe 'smart-pull' do
|
|
12
12
|
mkdir remote
|
13
13
|
cd remote
|
14
14
|
git init
|
15
|
+
git config --local user.name 'Maxwell Smart'
|
16
|
+
git config --local user.email 'agent86@control.gov'
|
17
|
+
git config --local core.pager 'cat'
|
15
18
|
echo 'hurr durr' > README
|
16
19
|
mkdir lib
|
17
20
|
echo 'puts "pro hax"' > lib/codes.rb
|
18
21
|
git add .
|
19
22
|
git commit -m 'first'
|
20
23
|
cd ..
|
21
|
-
|
22
24
|
git clone remote/.git local
|
25
|
+
cd local
|
26
|
+
git config --local user.name 'Agent 99'
|
27
|
+
git config --local user.email 'agent99@control.gov'
|
28
|
+
git config --local core.pager 'cat'
|
23
29
|
]
|
24
30
|
end
|
25
31
|
|
@@ -68,7 +74,7 @@ describe 'smart-pull' do
|
|
68
74
|
out.should report("Local branch 'master' has not moved on. Fast-forwarding.")
|
69
75
|
out.should report("Executing: git merge --ff-only origin/master")
|
70
76
|
out.should report(/Updating [^\.]+..[^\.]+/)
|
71
|
-
out.should report(
|
77
|
+
out.should report(/1 files? changed, 1 insertions?\(\+\)(, 0 deletions\(-\))?$/)
|
72
78
|
end
|
73
79
|
|
74
80
|
it "should not stash before fast-forwarding if untracked files are present" do
|
@@ -79,7 +85,7 @@ describe 'smart-pull' do
|
|
79
85
|
local_dir.should have_git_status({:untracked => ['noob']})
|
80
86
|
out = run_command(local_dir, 'smart-pull')
|
81
87
|
out.should report("Executing: git merge --ff-only origin/master")
|
82
|
-
out.should report(
|
88
|
+
out.should report(/1 files? changed, 1 insertions?\(\+\)(, 0 deletions\(-\))?$/)
|
83
89
|
local_dir.should have_git_status({:untracked => ['noob']})
|
84
90
|
end
|
85
91
|
|
@@ -95,7 +101,7 @@ describe 'smart-pull' do
|
|
95
101
|
out.should report("Working directory dirty. Stashing...")
|
96
102
|
out.should report("Executing: git stash")
|
97
103
|
out.should report("Executing: git merge --ff-only origin/master")
|
98
|
-
out.should report(
|
104
|
+
out.should report(/1 files? changed, 1 insertions?\(\+\)(, 0 deletions\(-\))?$/)
|
99
105
|
out.should report("Reapplying local changes...")
|
100
106
|
out.should report("Executing: git stash pop")
|
101
107
|
local_dir.should have_git_status({:added => ['noob'], :modified => ['lib/codes.rb']})
|
@@ -159,4 +165,51 @@ describe 'smart-pull' do
|
|
159
165
|
local_dir.should have_last_few_commits(['local changes', 'upstream changes', 'first'])
|
160
166
|
end
|
161
167
|
end
|
168
|
+
|
169
|
+
context 'with a submodule' do
|
170
|
+
before do
|
171
|
+
%x[
|
172
|
+
cd #{WORKING_DIR}
|
173
|
+
mkdir submodule
|
174
|
+
cd submodule
|
175
|
+
git init
|
176
|
+
git config --local user.name 'The Chief'
|
177
|
+
git config --local user.email 'agentq@control.gov'
|
178
|
+
git config --local core.pager 'cat'
|
179
|
+
echo 'Unusual, but effective.' > README
|
180
|
+
git add .
|
181
|
+
git commit -m 'first'
|
182
|
+
cd ..
|
183
|
+
cd local
|
184
|
+
git submodule add "${PWD}/../submodule/.git" submodule
|
185
|
+
git commit -am 'Add submodule'
|
186
|
+
]
|
187
|
+
end
|
188
|
+
let(:submodule_dir) { local_dir + '/submodule' }
|
189
|
+
|
190
|
+
it 'can smart-pull the repo containing the submodule' do
|
191
|
+
out = run_command(local_dir, 'smart-pull')
|
192
|
+
out.should report('Executing: git fetch origin')
|
193
|
+
out.should report("Remote branch 'origin/master' has not moved on.")
|
194
|
+
out.should report("You have 1 new commit on 'master'.")
|
195
|
+
end
|
196
|
+
|
197
|
+
it 'can smart-pull the submodule' do
|
198
|
+
out = run_command(submodule_dir, 'smart-pull')
|
199
|
+
out.should report('Executing: git fetch origin')
|
200
|
+
out.should report("Neither your local branch 'master', nor the remote branch 'origin/master' have moved on.")
|
201
|
+
out.should report('Already up-to-date')
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
context 'outside of a repo' do
|
206
|
+
it 'should report a meaningful error' do
|
207
|
+
Dir.mktmpdir do |non_repo_dir|
|
208
|
+
out = run_command(non_repo_dir, 'smart-pull')
|
209
|
+
out.should report 'You need to run this from within a Git directory'
|
210
|
+
out.should report 'Current working directory: '
|
211
|
+
out.should report 'Expected .git directory: '
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
162
215
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-smart
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.11
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Glen Maddern
|
@@ -13,48 +12,60 @@ date: 2011-01-06 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: colorize
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
25
27
|
- !ruby/object:Gem::Dependency
|
26
28
|
name: rspec
|
27
|
-
requirement:
|
28
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
|
-
- -
|
31
|
+
- - ">="
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: 2.7.0
|
33
34
|
type: :development
|
34
35
|
prerelease: false
|
35
|
-
version_requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.7.0
|
36
41
|
- !ruby/object:Gem::Dependency
|
37
42
|
name: rcov
|
38
|
-
requirement:
|
39
|
-
none: false
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
40
44
|
requirements:
|
41
|
-
- -
|
45
|
+
- - ">="
|
42
46
|
- !ruby/object:Gem::Version
|
43
47
|
version: '0'
|
44
48
|
type: :development
|
45
49
|
prerelease: false
|
46
|
-
version_requirements:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
47
55
|
- !ruby/object:Gem::Dependency
|
48
56
|
name: rocco
|
49
|
-
requirement:
|
50
|
-
none: false
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
51
58
|
requirements:
|
52
|
-
- -
|
59
|
+
- - ">="
|
53
60
|
- !ruby/object:Gem::Version
|
54
61
|
version: '0'
|
55
62
|
type: :development
|
56
63
|
prerelease: false
|
57
|
-
version_requirements:
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
58
69
|
description: Installs some additional 'smart' git commands, like `git smart-pull`.
|
59
70
|
email: glenmaddern@gmail.com
|
60
71
|
executables:
|
@@ -66,6 +77,15 @@ extra_rdoc_files:
|
|
66
77
|
- LICENSE.txt
|
67
78
|
- README.md
|
68
79
|
files:
|
80
|
+
- Gemfile
|
81
|
+
- Gemfile.lock
|
82
|
+
- LICENSE.txt
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
85
|
+
- VERSION
|
86
|
+
- bin/git-smart-log
|
87
|
+
- bin/git-smart-merge
|
88
|
+
- bin/git-smart-pull
|
69
89
|
- docs/images/git-smart.png
|
70
90
|
- docs/images/smart-log-comparison.png
|
71
91
|
- docs/images/smart-pull-screenshot.png
|
@@ -85,46 +105,32 @@ files:
|
|
85
105
|
- lib/git-smart/git_repo.rb
|
86
106
|
- lib/git-smart/git_smart.rb
|
87
107
|
- lib/git-smart/safe_shell.rb
|
88
|
-
- Gemfile
|
89
|
-
- Gemfile.lock
|
90
|
-
- LICENSE.txt
|
91
|
-
- README.md
|
92
|
-
- Rakefile
|
93
|
-
- VERSION
|
94
108
|
- spec/smart-merge_failures_spec.rb
|
95
109
|
- spec/smart-merge_spec.rb
|
96
110
|
- spec/smart-pull_spec.rb
|
97
111
|
- spec/spec_helper.rb
|
98
|
-
- !binary |-
|
99
|
-
YmluL2dpdC1zbWFydC1sb2c=
|
100
|
-
- !binary |-
|
101
|
-
YmluL2dpdC1zbWFydC1tZXJnZQ==
|
102
|
-
- !binary |-
|
103
|
-
YmluL2dpdC1zbWFydC1wdWxs
|
104
112
|
homepage: http://github.com/geelen/git-smart
|
105
113
|
licenses:
|
106
114
|
- MIT
|
115
|
+
metadata: {}
|
107
116
|
post_install_message:
|
108
117
|
rdoc_options: []
|
109
118
|
require_paths:
|
110
119
|
- lib
|
111
120
|
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
-
none: false
|
113
121
|
requirements:
|
114
|
-
- -
|
122
|
+
- - ">="
|
115
123
|
- !ruby/object:Gem::Version
|
116
124
|
version: '0'
|
117
125
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
-
none: false
|
119
126
|
requirements:
|
120
|
-
- -
|
127
|
+
- - ">="
|
121
128
|
- !ruby/object:Gem::Version
|
122
129
|
version: '0'
|
123
130
|
requirements: []
|
124
|
-
|
125
|
-
rubygems_version: 1.8.11
|
131
|
+
rubygems_version: 3.0.3.1
|
126
132
|
signing_key:
|
127
|
-
specification_version:
|
133
|
+
specification_version: 4
|
128
134
|
summary: Add some smarts to your git workflow
|
129
135
|
test_files:
|
130
136
|
- spec/smart-merge_failures_spec.rb
|