git-smart 0.1.0 → 0.1.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/README.md CHANGED
@@ -7,6 +7,32 @@ Adds some additional git commands to add some smarts to your workflow. These com
7
7
  0. All git commands that modify the repository should be shown to the user - hopefully this helps the user eventually learn the underlying git commands, and when they're relevant.
8
8
  0. All git commands, destructive or not, and their output should be shown to the user with the -v/--verbose flag.
9
9
 
10
+ # Installing
11
+
12
+ First, grab the gem:
13
+
14
+ gem install git-smart
15
+
16
+ List the commands you can install (currently only the one):
17
+
18
+ git-smart list
19
+
20
+ Install away!
21
+
22
+ git-smart install smart-pull
23
+
24
+ OR
25
+
26
+ git-smart install --all
27
+
28
+ That'll put an executable file for each command in your ~/bin directory if that exists and is on the path, /usr/local/bin otherwise.
29
+
30
+ # Using
31
+
32
+ Git allows custom commands with a simple convention - `git xyz` tries to find an executable `git-xyz` on the path. So, to run the smart-pull command, simply run:
33
+
34
+ git smart-pull
35
+
10
36
  ## git-smart-pull
11
37
 
12
38
  Calling 'git smart-pull' will fetch remote tracked changes and reapply your work on top of it. It's like a much, much smarter version of 'git pull --rebase'.
@@ -25,8 +51,7 @@ This is how it works:
25
51
  0. rebase -p onto the remote
26
52
  0. stash pop
27
53
  0. update ORIG\_HEAD to be the previous local HEAD, as expected (rebase -p doesn't set ORIG\_HEAD correctly)
28
- 0. Output a summary of what just happened, as well as any new or updated branches that came down with the last fetch.
29
- 0. Output a big, green GIT UP GOOD or red GIT UP BAD, depending on how things went.
54
+ 0. Output a big green or red message so, at a glance, you know if things worked or not.
30
55
 
31
56
  # Contributing to git-smart
32
57
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'trollop'
4
-
5
3
  class GitSmartBinary
6
4
  USAGE = %Q{Usage:
7
5
  git-smart list List all the git commands that can be installed
@@ -33,7 +31,7 @@ class GitSmartBinary
33
31
  else
34
32
  args
35
33
  end
36
- install_dir = File.dirname(`which git`)
34
+ install_dir = get_install_dir
37
35
  puts "Installing #{cmds.join(', ')} to #{install_dir}:"
38
36
  cmds.each { |cmd|
39
37
  filename = "#{install_dir}/git-#{cmd}"
@@ -43,13 +41,24 @@ class GitSmartBinary
43
41
  require 'rubygems'
44
42
  require 'git-smart'
45
43
 
46
- GitSmart.run(#{cmd}, ARGV)
44
+ GitSmart.run('#{cmd}', ARGV)
47
45
  }
48
46
  }
49
47
  `chmod a+x #{filename}`
50
48
  puts "Wrote #{filename}"
51
49
  }
52
50
  end
51
+
52
+ private
53
+
54
+ def get_install_dir
55
+ home_bin = File.expand_path('~/bin')
56
+ if File.exists?(home_bin) && ENV['PATH'].split(':').include?(home_bin)
57
+ home_bin
58
+ else
59
+ '/usr/local/bin'
60
+ end
61
+ end
53
62
  end
54
63
 
55
64
  case ARGV.shift
@@ -0,0 +1,81 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{git-smart}
8
+ s.version = "0.1.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Glen Maddern"]
12
+ s.date = %q{2011-01-04}
13
+ s.default_executable = %q{git-smart}
14
+ s.description = %q{Installs some additional 'smart' git commands, like `git smart-pull`.}
15
+ s.email = %q{glenmaddern@gmail.com}
16
+ s.executables = ["git-smart"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.md"
20
+ ]
21
+ s.files = [
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.md",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "bin/git-smart",
29
+ "git-smart.gemspec",
30
+ "lib/commands/smart-pull.rb",
31
+ "lib/core_ext/array.rb",
32
+ "lib/core_ext/hash.rb",
33
+ "lib/core_ext/object.rb",
34
+ "lib/git-smart.rb",
35
+ "lib/git-smart/exceptions.rb",
36
+ "lib/git-smart/execution_context.rb",
37
+ "lib/git-smart/git_repo.rb",
38
+ "lib/git-smart/git_smart.rb",
39
+ "lib/git-smart/safe_shell.rb",
40
+ "spec/smart-pull_spec.rb",
41
+ "spec/spec_helper.rb"
42
+ ]
43
+ s.homepage = %q{http://github.com/geelen/git-smart}
44
+ s.licenses = ["MIT"]
45
+ s.require_paths = ["lib"]
46
+ s.rubygems_version = %q{1.3.7}
47
+ s.summary = %q{Add some smarts to your git workflow}
48
+ s.test_files = [
49
+ "spec/smart-pull_spec.rb",
50
+ "spec/spec_helper.rb"
51
+ ]
52
+
53
+ if s.respond_to? :specification_version then
54
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
55
+ s.specification_version = 3
56
+
57
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
58
+ s.add_runtime_dependency(%q<colorize>, [">= 0"])
59
+ s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
60
+ s.add_development_dependency(%q<rcov>, [">= 0"])
61
+ s.add_development_dependency(%q<ruby-debug>, [">= 0"])
62
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
63
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
64
+ else
65
+ s.add_dependency(%q<colorize>, [">= 0"])
66
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
67
+ s.add_dependency(%q<rcov>, [">= 0"])
68
+ s.add_dependency(%q<ruby-debug>, [">= 0"])
69
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
70
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
71
+ end
72
+ else
73
+ s.add_dependency(%q<colorize>, [">= 0"])
74
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
75
+ s.add_dependency(%q<rcov>, [">= 0"])
76
+ s.add_dependency(%q<ruby-debug>, [">= 0"])
77
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
78
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
79
+ end
80
+ end
81
+
@@ -14,7 +14,7 @@ GitSmart.register 'smart-pull' do |repo, args|
14
14
 
15
15
  # Fetch the remote. This pulls down all new commits from the server, not just our branch,
16
16
  # but generally that's a good thing. This is the only communication we need to do with the server.
17
- puts_with_done("Fetching '#{tracking_remote}'") { repo.fetch(tracking_remote) }
17
+ repo.fetch!(tracking_remote)
18
18
 
19
19
  # Try grabbing the tracking branch from the config. If it doesn't exist,
20
20
  # notify the user and choose the branch of the same name
@@ -51,18 +51,24 @@ GitSmart.register 'smart-pull' do |repo, args|
51
51
  puts "No uncommitted changes, no need to stash."
52
52
  end
53
53
 
54
+ success_messages = []
55
+
54
56
  if merge_base == head
55
57
  puts "Local branch '#{branch}' has not moved on. Fast-forwarding..."
56
58
  repo.fast_forward!(upstream_branch)
59
+ success_messages << "Fast forwarded from #{head[0,7]} to #{remote[0,7]}"
57
60
  else
58
61
  note "Both local and remote branches have moved on. Branch 'master' needs to be rebased onto 'origin/master'"
59
62
  repo.rebase_preserving_merges!(upstream_branch)
63
+ success_messages << "HEAD moved from #{head[0,7]} to #{repo.sha('HEAD')[0,7]}."
60
64
  end
61
65
 
62
66
  if stash_required
63
67
  note "Reapplying local changes..."
64
68
  repo.stash_pop!
65
69
  end
70
+
71
+ success ["All good.", *success_messages].join(" ")
66
72
  end
67
73
 
68
74
  end
@@ -26,8 +26,8 @@ class GitRepo
26
26
  end
27
27
  end
28
28
 
29
- def fetch(remote)
30
- git('fetch', remote)
29
+ def fetch!(remote)
30
+ log_git('fetch', remote)
31
31
  end
32
32
 
33
33
  def merge_base(ref_a, ref_b)
@@ -25,7 +25,7 @@ describe 'smart-pull' do
25
25
 
26
26
  it "should tell us there's nothing to do" do
27
27
  out = run_command(local_dir, 'smart-pull')
28
- out.should report("Fetching 'origin'")
28
+ out.should report("Executing: git fetch origin")
29
29
  out.should report("Neither your local branch 'master', nor the remote branch 'origin/master' have moved on.")
30
30
  out.should report("Already up-to-date")
31
31
  end
@@ -43,7 +43,7 @@ describe 'smart-pull' do
43
43
 
44
44
  it "should report that no remote changes were found" do
45
45
  out = run_command(local_dir, 'smart-pull')
46
- out.should report("Fetching 'origin'")
46
+ out.should report("Executing: git fetch origin")
47
47
  out.should report("Remote branch 'origin/master' has not moved on.")
48
48
  out.should report("Already up-to-date")
49
49
  end
@@ -61,7 +61,8 @@ describe 'smart-pull' do
61
61
 
62
62
  it "should fast-forward" do
63
63
  out = run_command(local_dir, 'smart-pull')
64
- out.should report("Fetching 'origin'")
64
+ out.should report("Executing: git fetch origin")
65
+ out.should report(/master +-> +origin\/master/)
65
66
  out.should report("There is 1 new commit on master.")
66
67
  out.should report("No uncommitted changes, no need to stash.")
67
68
  out.should report("Local branch 'master' has not moved on. Fast-forwarding.")
@@ -119,7 +120,8 @@ describe 'smart-pull' do
119
120
 
120
121
  it "should rebase" do
121
122
  out = run_command(local_dir, 'smart-pull')
122
- out.should report("Fetching 'origin'")
123
+ out.should report("Executing: git fetch origin")
124
+ out.should report(/master +-> +origin\/master/)
123
125
  out.should report("There is 1 new commit on master.")
124
126
  out.should report("Both local and remote branches have moved on. Branch 'master' needs to be rebased onto 'origin/master'")
125
127
  out.should report("Executing: git rebase -p origin/master")
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-smart
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Glen Maddern
@@ -125,6 +125,7 @@ files:
125
125
  - Rakefile
126
126
  - VERSION
127
127
  - bin/git-smart
128
+ - git-smart.gemspec
128
129
  - lib/commands/smart-pull.rb
129
130
  - lib/core_ext/array.rb
130
131
  - lib/core_ext/hash.rb