git-smart 0.1.11 → 0.1.12

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 64ad55375b56d448e73868a6f94752cfdff26dc5ab5fda21c36e4ee25e7388cf
4
- data.tar.gz: 795a52c8fc520bbc3c37cdc5b66b36a2482f9820f19e1da6cdebd8365a1531bd
3
+ metadata.gz: a4bd50ad86b016ea6af4c9b2df62562bfbc296c94d8801b0cec1d52771c1d285
4
+ data.tar.gz: 670bdb88c994280c6c1daead755674ac162d1902762e465cfcc64111a7733681
5
5
  SHA512:
6
- metadata.gz: c5c6c4acd4930017ea59a695a457232f62fc18807adbf6f93ec65f73289cb9377cbd8fb9a00758ce78e44ee76b29cf979451db27c21313ead3a6f21d7806a331
7
- data.tar.gz: 9644dcbaaa3e69c34f53d42c87b21cf8aacd29ec7b6d8241694882dcdbcd0c1e1670a0b40354c70cc7d4b3f467a312349295fa85c7ea235344cfceeabbfd915e
6
+ metadata.gz: e266373a717d627c54fb64d902c8103e029f82746f3092302de7063622a03d61254a8014a4b224056d4c4da73c9c11c3300dd3c4574f1550a0f916b8e4c074a1
7
+ data.tar.gz: 3b4c75ec3931c94ab3eba06049f50f7f09589cf6b0c9e0319e717de70e74c673a25ed1b44ab86ff04d2e6fbfb75c8109811c86b72ea9c969827fd45fd9e535d2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.11
1
+ 0.1.12
@@ -20,7 +20,7 @@ class GitRepo
20
20
  def git_dir
21
21
  gitdir = Pathname.new(@dir).join('.git')
22
22
 
23
- unless File.exists?(gitdir)
23
+ unless File.exist?(gitdir)
24
24
  @dir = git('rev-parse', '--show-toplevel').chomp
25
25
  gitdir = Pathname.new(@dir).join('.git') unless @dir.empty?
26
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-smart
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Glen Maddern
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2011-01-06 00:00:00.000000000 Z
11
+ date: 2026-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -16,56 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '0.8'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '0.8'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 2.7.0
33
+ version: '3.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: 2.7.0
41
- - !ruby/object:Gem::Dependency
42
- name: rcov
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
38
+ - - "~>"
53
39
  - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: rocco
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
40
+ version: '3.0'
69
41
  description: Installs some additional 'smart' git commands, like `git smart-pull`.
70
42
  email: glenmaddern@gmail.com
71
43
  executables:
@@ -77,11 +49,8 @@ extra_rdoc_files:
77
49
  - LICENSE.txt
78
50
  - README.md
79
51
  files:
80
- - Gemfile
81
- - Gemfile.lock
82
52
  - LICENSE.txt
83
53
  - README.md
84
- - Rakefile
85
54
  - VERSION
86
55
  - bin/git-smart-log
87
56
  - bin/git-smart-merge
@@ -105,15 +74,13 @@ files:
105
74
  - lib/git-smart/git_repo.rb
106
75
  - lib/git-smart/git_smart.rb
107
76
  - lib/git-smart/safe_shell.rb
108
- - spec/smart-merge_failures_spec.rb
109
- - spec/smart-merge_spec.rb
110
- - spec/smart-pull_spec.rb
111
- - spec/spec_helper.rb
112
- homepage: http://github.com/geelen/git-smart
77
+ homepage: https://github.com/geelen/git-smart
113
78
  licenses:
114
79
  - MIT
115
- metadata: {}
116
- post_install_message:
80
+ metadata:
81
+ source_code_uri: https://github.com/geelen/git-smart
82
+ changelog_uri: https://github.com/geelen/git-smart/commits/main
83
+ post_install_message:
117
84
  rdoc_options: []
118
85
  require_paths:
119
86
  - lib
@@ -121,19 +88,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
121
88
  requirements:
122
89
  - - ">="
123
90
  - !ruby/object:Gem::Version
124
- version: '0'
91
+ version: 2.7.0
125
92
  required_rubygems_version: !ruby/object:Gem::Requirement
126
93
  requirements:
127
94
  - - ">="
128
95
  - !ruby/object:Gem::Version
129
96
  version: '0'
130
97
  requirements: []
131
- rubygems_version: 3.0.3.1
132
- signing_key:
98
+ rubygems_version: 3.5.22
99
+ signing_key:
133
100
  specification_version: 4
134
101
  summary: Add some smarts to your git workflow
135
- test_files:
136
- - spec/smart-merge_failures_spec.rb
137
- - spec/smart-merge_spec.rb
138
- - spec/smart-pull_spec.rb
139
- - spec/spec_helper.rb
102
+ test_files: []
data/Gemfile DELETED
@@ -1,10 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'colorize'
4
-
5
- group :development do
6
- gem 'rspec'
7
- gem 'simplecov'
8
- gem 'rocco'
9
- gem 'rake'
10
- end
data/Gemfile.lock DELETED
@@ -1,36 +0,0 @@
1
- GEM
2
- remote: https://rubygems.org/
3
- specs:
4
- colorize (0.5.8)
5
- diff-lcs (1.1.3)
6
- docile (1.1.1)
7
- multi_json (1.8.2)
8
- mustache (0.99.4)
9
- rake (10.0.3)
10
- redcarpet (1.17.2)
11
- rocco (0.8.2)
12
- mustache
13
- redcarpet
14
- rspec (2.7.0)
15
- rspec-core (~> 2.7.0)
16
- rspec-expectations (~> 2.7.0)
17
- rspec-mocks (~> 2.7.0)
18
- rspec-core (2.7.1)
19
- rspec-expectations (2.7.0)
20
- diff-lcs (~> 1.1.2)
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)
27
-
28
- PLATFORMS
29
- ruby
30
-
31
- DEPENDENCIES
32
- colorize
33
- rake
34
- rocco
35
- rspec
36
- simplecov
data/Rakefile DELETED
@@ -1,71 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler'
3
-
4
- begin
5
- Bundler.setup(:default, :development)
6
- rescue Bundler::BundlerError => e
7
- $stderr.puts e.message
8
- $stderr.puts "Run `bundle install` to install missing gems"
9
- exit e.status_code
10
- end
11
-
12
- require 'rake'
13
-
14
- require 'rspec/core'
15
- require 'rspec/core/rake_task'
16
- RSpec::Core::RakeTask.new(:spec) do |spec|
17
- spec.pattern = FileList['spec/**/*_spec.rb']
18
- end
19
-
20
- RSpec::Core::RakeTask.new(:rcov) do |spec|
21
- spec.pattern = 'spec/**/*_spec.rb'
22
- spec.rcov = true
23
- end
24
-
25
- task :default => :spec
26
-
27
- require 'rdoc/task'
28
- Rake::RDocTask.new do |rdoc|
29
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
30
-
31
- rdoc.rdoc_dir = 'rdoc'
32
- rdoc.title = "git-smart #{version}"
33
- rdoc.rdoc_files.include('README*')
34
- rdoc.rdoc_files.include('lib/**/*.rb')
35
- end
36
-
37
- desc "Generate the rocco docs"
38
- task :rocco do
39
- base_dir = File.dirname(__FILE__)
40
- %x[cd #{base_dir}/lib/commands && rocco *.rb -o ../../docs]
41
- %x[cd #{base_dir} && git add docs]
42
- end
43
-
44
- task :release => :rocco
45
-
46
- desc "Generate a binary for each of our commands"
47
- task :generate_binaries do
48
- base_dir = File.dirname(__FILE__)
49
- require "#{base_dir}/lib/git-smart"
50
-
51
- require 'fileutils'
52
- FileUtils.mkdir_p "#{base_dir}/bin"
53
- GitSmart.commands.keys.each { |cmd|
54
- filename = "#{base_dir}/bin/git-#{cmd}"
55
- File.open(filename, 'w') { |out|
56
- out.puts %Q{#!/usr/bin/env ruby
57
-
58
- $:.unshift(File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib'))
59
-
60
- require 'git-smart'
61
-
62
- GitSmart.run('#{cmd}', ARGV)
63
- }
64
- }
65
- `chmod a+x #{filename}`
66
- `cd #{base_dir} && git add #{filename}`
67
- puts "Wrote #{filename}"
68
- }
69
- end
70
-
71
- task :build => :generate_binaries
@@ -1,49 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- require 'fileutils'
4
-
5
- describe 'smart-merge with failures' do
6
- def local_dir; WORKING_DIR + '/local'; end
7
-
8
- before :each do
9
- %x[
10
- cd #{WORKING_DIR}
11
- mkdir local
12
- cd local
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'
17
- echo -e 'one\ntwo\nthree\nfour\n' > README
18
- mkdir lib
19
- echo 'puts "pro hax"' > lib/codes.rb
20
- git add .
21
- git commit -m 'first'
22
- ]
23
- end
24
-
25
- context "with conflicting changes on master and newbranch" do
26
- before :each do
27
- %x[
28
- cd #{local_dir}
29
- git checkout -b newbranch 2> /dev/null
30
- echo 'one\nnewbranch changes\nfour\n' > README
31
- git commit -am 'newbranch_commit'
32
-
33
- git checkout master 2> /dev/null
34
-
35
- echo 'one\nmaster changes\nfour\n' > README
36
- git commit -am 'master_commit'
37
- ]
38
- end
39
-
40
- it "should report the failure and give instructions to the user" do
41
- out = run_command(local_dir, 'smart-merge', 'newbranch')
42
- local_dir.should have_git_status(:conflicted => ['README'])
43
- out.should_not report("All good")
44
- out.should report("Executing: git merge --no-ff newbranch")
45
- out.should report("CONFLICT (content): Merge conflict in README")
46
- out.should report("Automatic merge failed; fix conflicts and then commit the result.")
47
- end
48
- end
49
- end
@@ -1,104 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- require 'fileutils'
4
-
5
- describe 'smart-merge' do
6
- def local_dir; WORKING_DIR + '/local'; end
7
-
8
- before :each do
9
- %x[
10
- cd #{WORKING_DIR}
11
- mkdir local
12
- cd local
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'
17
- echo 'hurr durr' > README
18
- mkdir lib
19
- echo 'puts "pro hax"' > lib/codes.rb
20
- git add .
21
- git commit -m 'first'
22
- ]
23
- end
24
-
25
- it "should require an argument" do
26
- out = run_command(local_dir, 'smart-merge')
27
- out.should report("Usage: git smart-merge ref")
28
- end
29
-
30
- it "should require a valid branch" do
31
- out = run_command(local_dir, 'smart-merge', 'foo')
32
- out.should report("Branch to merge 'foo' not recognised by git!")
33
- end
34
-
35
- it "should report nothing to do if the branch hasn't moved on" do
36
- %x[
37
- cd #{local_dir}
38
- git branch unmoved
39
- ]
40
- out = run_command(local_dir, 'smart-merge', 'unmoved')
41
- out.should report("Branch 'unmoved' has no new commits. Nothing to merge in.")
42
- out.should report("Already up-to-date.")
43
- end
44
-
45
- context "with local changes to newbranch" do
46
- before :each do
47
- %x[
48
- cd #{local_dir}
49
- git checkout -b newbranch 2> /dev/null
50
- echo 'moar things!' >> README
51
- echo 'puts "moar code!"' >> lib/moar.rb
52
- git add .
53
- git commit -m 'moar'
54
-
55
- git checkout master 2> /dev/null
56
- ]
57
- end
58
-
59
- it "should merge --no-ff, despite the branch being fast-forwardable" do
60
- out = run_command(local_dir, 'smart-merge', 'newbranch')
61
- out.should report("Branch 'newbranch' has diverged by 1 commit. Merging in.")
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.")
63
- out.should report("Executing: git merge --no-ff newbranch")
64
- out.should report(/2 files changed, 2 insertions\(\+\)(, 0 deletions\(-\))?$/)
65
- out.should report(/All good\. Created merge commit [\w]{7}\./)
66
- end
67
-
68
- context "and changes on master" do
69
- before :each do
70
- %x[
71
- cd #{local_dir}
72
- echo "puts 'moar codes too!'" >> lib/codes.rb
73
- git add .
74
- git commit -m 'changes on master'
75
- ]
76
- end
77
-
78
- it "should merge in ok" do
79
- out = run_command(local_dir, 'smart-merge', 'newbranch')
80
- out.should report("Branch 'newbranch' has diverged by 1 commit. Merging in.")
81
- out.should report("Branch 'master' has 1 new commit since 'newbranch' diverged.")
82
- out.should report("Executing: git merge --no-ff newbranch")
83
- out.should report(/2 files changed, 2 insertions\(\+\)(, 0 deletions\(-\))?$/)
84
- out.should report(/All good\. Created merge commit [\w]{7}\./)
85
- end
86
-
87
- it "should stash then merge if working tree is dirty" do
88
- %x[
89
- cd #{local_dir}
90
- echo "i am nub" > noob
91
- echo "puts 'moar codes too!'" >> lib/codes.rb
92
- git add noob
93
- ]
94
- out = run_command(local_dir, 'smart-merge', 'newbranch')
95
- out.should report("Executing: git stash")
96
- out.should report("Executing: git merge --no-ff newbranch")
97
- out.should report(/2 files changed, 2 insertions\(\+\)(, 0 deletions\(-\))?$/)
98
- out.should report("Reapplying local changes...")
99
- out.should report("Executing: git stash pop")
100
- out.should report(/All good\. Created merge commit [\w]{7}\./)
101
- end
102
- end
103
- end
104
- end
@@ -1,215 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- require 'fileutils'
4
-
5
- describe 'smart-pull' do
6
- def local_dir; WORKING_DIR + '/local'; end
7
- def remote_dir; WORKING_DIR + '/remote'; end
8
-
9
- before :each do
10
- %x[
11
- cd #{WORKING_DIR}
12
- mkdir remote
13
- cd remote
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'
18
- echo 'hurr durr' > README
19
- mkdir lib
20
- echo 'puts "pro hax"' > lib/codes.rb
21
- git add .
22
- git commit -m 'first'
23
- cd ..
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'
29
- ]
30
- end
31
-
32
- it "should tell us there's nothing to do" do
33
- out = run_command(local_dir, 'smart-pull')
34
- out.should report("Executing: git fetch origin")
35
- out.should report("Neither your local branch 'master', nor the remote branch 'origin/master' have moved on.")
36
- out.should report("Already up-to-date")
37
- end
38
-
39
- context "with only local changes" do
40
- before :each do
41
- %x[
42
- cd #{local_dir}
43
- echo 'moar things!' >> README
44
- echo 'puts "moar code!"' >> lib/moar.rb
45
- git add .
46
- git commit -m 'moar'
47
- ]
48
- end
49
-
50
- it "should report that no remote changes were found" do
51
- out = run_command(local_dir, 'smart-pull')
52
- out.should report("Executing: git fetch origin")
53
- out.should report("Remote branch 'origin/master' has not moved on.")
54
- out.should report("You have 1 new commit on 'master'.")
55
- out.should report("Already up-to-date")
56
- end
57
- end
58
-
59
- context "with only remote changes" do
60
- before :each do
61
- %x[
62
- cd #{remote_dir}
63
- echo 'changed on the server!' >> README
64
- git add .
65
- git commit -m 'upstream changes'
66
- ]
67
- end
68
-
69
- it "should fast-forward" do
70
- out = run_command(local_dir, 'smart-pull')
71
- out.should report("Executing: git fetch origin")
72
- out.should report(/master +-> +origin\/master/)
73
- out.should report("There is 1 new commit on 'origin/master'.")
74
- out.should report("Local branch 'master' has not moved on. Fast-forwarding.")
75
- out.should report("Executing: git merge --ff-only origin/master")
76
- out.should report(/Updating [^\.]+..[^\.]+/)
77
- out.should report(/1 files? changed, 1 insertions?\(\+\)(, 0 deletions\(-\))?$/)
78
- end
79
-
80
- it "should not stash before fast-forwarding if untracked files are present" do
81
- %x[
82
- cd #{local_dir}
83
- echo "i am nub" > noob
84
- ]
85
- local_dir.should have_git_status({:untracked => ['noob']})
86
- out = run_command(local_dir, 'smart-pull')
87
- out.should report("Executing: git merge --ff-only origin/master")
88
- out.should report(/1 files? changed, 1 insertions?\(\+\)(, 0 deletions\(-\))?$/)
89
- local_dir.should have_git_status({:untracked => ['noob']})
90
- end
91
-
92
- it "should stash, fast forward, pop if there are local changes" do
93
- %x[
94
- cd #{local_dir}
95
- echo "i am nub" > noob
96
- echo "puts 'moar codes too!'" >> lib/codes.rb
97
- git add noob
98
- ]
99
- local_dir.should have_git_status({:added => ['noob'], :modified => ['lib/codes.rb']})
100
- out = run_command(local_dir, 'smart-pull')
101
- out.should report("Working directory dirty. Stashing...")
102
- out.should report("Executing: git stash")
103
- out.should report("Executing: git merge --ff-only origin/master")
104
- out.should report(/1 files? changed, 1 insertions?\(\+\)(, 0 deletions\(-\))?$/)
105
- out.should report("Reapplying local changes...")
106
- out.should report("Executing: git stash pop")
107
- local_dir.should have_git_status({:added => ['noob'], :modified => ['lib/codes.rb']})
108
- end
109
- end
110
-
111
- context "with diverged branches" do
112
- before :each do
113
- %x[
114
- cd #{remote_dir}
115
- echo 'changed on the server!' >> README
116
- git add .
117
- git commit -m 'upstream changes'
118
-
119
- cd #{local_dir}
120
- echo "puts 'moar codes too!'" >> lib/codes.rb
121
- git add .
122
- git commit -m 'local changes'
123
- ]
124
- end
125
-
126
- it "should rebase" do
127
- out = run_command(local_dir, 'smart-pull')
128
- out.should report("Executing: git fetch origin")
129
- out.should report(/master +-> +origin\/master/)
130
- out.should report("There is 1 new commit on 'origin/master'.")
131
- out.should report("You have 1 new commit on 'master'.")
132
- out.should report("Both local and remote branches have moved on. Branch 'master' needs to be rebased onto 'origin/master'")
133
- out.should report("Executing: git rebase -p origin/master")
134
- out.should report("Successfully rebased and updated refs/heads/master.")
135
- local_dir.should have_last_few_commits(['local changes', 'upstream changes', 'first'])
136
- end
137
-
138
- it "should not stash before rebasing if untracked files are present" do
139
- %x[
140
- cd #{local_dir}
141
- echo "i am nub" > noob
142
- ]
143
- local_dir.should have_git_status({:untracked => ['noob']})
144
- out = run_command(local_dir, 'smart-pull')
145
- out.should report("Executing: git rebase -p origin/master")
146
- out.should report("Successfully rebased and updated refs/heads/master.")
147
- local_dir.should have_git_status({:untracked => ['noob']})
148
- local_dir.should have_last_few_commits(['local changes', 'upstream changes', 'first'])
149
- end
150
-
151
- it "should stash, rebase, pop if there are local uncommitted changes" do
152
- %x[
153
- cd #{local_dir}
154
- echo "i am nub" > noob
155
- echo "puts 'moar codes too!'" >> lib/codes.rb
156
- git add noob
157
- ]
158
- local_dir.should have_git_status({:added => ['noob'], :modified => ['lib/codes.rb']})
159
- out = run_command(local_dir, 'smart-pull')
160
- out.should report("Working directory dirty. Stashing...")
161
- out.should report("Executing: git stash")
162
- out.should report("Executing: git rebase -p origin/master")
163
- out.should report("Successfully rebased and updated refs/heads/master.")
164
- local_dir.should have_git_status({:added => ['noob'], :modified => ['lib/codes.rb']})
165
- local_dir.should have_last_few_commits(['local changes', 'upstream changes', 'first'])
166
- end
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
215
- end
data/spec/spec_helper.rb DELETED
@@ -1,65 +0,0 @@
1
- require 'rspec'
2
- require 'tmpdir'
3
-
4
- require File.dirname(__FILE__) + '/../lib/git-smart'
5
-
6
- WORKING_DIR = File.dirname(__FILE__) + '/working'
7
-
8
- RSpec.configure do |config|
9
- config.before :each do
10
- FileUtils.rm_rf WORKING_DIR
11
- FileUtils.mkdir_p WORKING_DIR
12
- end
13
-
14
- config.after :each do
15
- FileUtils.rm_rf WORKING_DIR
16
- end
17
- end
18
-
19
- def run_command(dir, command, *args)
20
- require 'stringio'
21
- $stdout = stdout = StringIO.new
22
-
23
- Dir.chdir(dir) { GitSmart.run(command, args) }
24
-
25
- $stdout = STDOUT
26
- stdout.string.split("\n")
27
- end
28
-
29
- RSpec::Matchers.define :report do |expected|
30
- failure_message_for_should do |actual|
31
- "expected to see #{expected.inspect}, got \n\n#{actual.map { |line| " #{line}" }.join("\n")}"
32
- end
33
- failure_message_for_should_not do |actual|
34
- "expected not to see #{expected.inspect} in \n\n#{actual.map { |line| " #{line}" }.join("\n")}"
35
- end
36
- match do |actual|
37
- actual.any? { |line| line[expected] }
38
- end
39
- end
40
-
41
-
42
- RSpec::Matchers.define :have_git_status do |expected|
43
- failure_message_for_should do |dir|
44
- "expected '#{dir}' to have git status of #{expected.inspect}, got #{GitRepo.new(dir).status.inspect}"
45
- end
46
- failure_message_for_should_not do |actual|
47
- "expected '#{dir}' to not have git status of #{expected.inspect}, got #{GitRepo.new(dir).status.inspect}"
48
- end
49
- match do |dir|
50
- GitRepo.new(dir).status == expected
51
- end
52
- end
53
-
54
-
55
- RSpec::Matchers.define :have_last_few_commits do |expected|
56
- failure_message_for_should do |dir|
57
- "expected '#{dir}' to have last few commits of #{expected.inspect}, got #{GitRepo.new(dir).last_commit_messages(expected.length).inspect}"
58
- end
59
- failure_message_for_should_not do |actual|
60
- "expected '#{dir}' to not have git status of #{expected.inspect}, got #{GitRepo.new(dir).last_commit_messages(expected.length).inspect}"
61
- end
62
- match do |dir|
63
- GitRepo.new(dir).last_commit_messages(expected.length) == expected
64
- end
65
- end