git-up 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +15 -6
- data/lib/git-up.rb +59 -29
- data/lib/git-up/version.rb +1 -1
- metadata +9 -9
data/README.md
CHANGED
@@ -15,16 +15,25 @@ although
|
|
15
15
|
configuration
|
16
16
|
-------------
|
17
17
|
|
18
|
-
`git-up` can
|
19
|
-
|
20
|
-
It slows the process down slightly, and is therefore enabled by setting `git-up.bundler.check` to `true` in your git config, either globally or per-project. To set it globally, run this command anywhere:
|
18
|
+
`git-up` has a few configuration options, which use git's configuration system. Each can be set either globally or per-project. To set an option globally, append the `--global` flag to `git config`, which you can run anywhere:
|
21
19
|
|
22
20
|
git config --global git-up.bundler.check true
|
23
21
|
|
24
|
-
To set it within a project, run
|
22
|
+
To set it within a project, run the command inside that project's directory and omit the `--global` flag:
|
25
23
|
|
24
|
+
cd myproject
|
26
25
|
git config git-up.bundler.check true
|
27
26
|
|
28
|
-
|
27
|
+
### `git-up.bundler.check [true|false]`
|
28
|
+
|
29
|
+
If set to `true`, `git-up` will check your app for any new bundled gems and suggest a `bundle install` if necessary.
|
30
|
+
|
31
|
+
It slows the process down slightly, and therefore defaults to `false`.
|
32
|
+
|
33
|
+
### `git-up.bundler.autoinstall [true|false]`
|
34
|
+
|
35
|
+
If you're even lazier, you can tell `git-up` to run `bundle install` for you if it finds missing gems. Make sure `git-up.bundler.check` is also set to `true` or it won't do anything.
|
36
|
+
|
37
|
+
### `git-up.fetch.prune [true|false]`
|
29
38
|
|
30
|
-
|
39
|
+
By default, `git-up` will append the `--prune` flag to the `git fetch` command if your git version supports it (1.6.6 or greater), telling it to [delete any branches which no longer exist on the remote](http://linux.die.net/man/1/git-fetch). Set this option to `false` to disable it.
|
data/lib/git-up.rb
CHANGED
@@ -3,47 +3,58 @@ require 'grit'
|
|
3
3
|
|
4
4
|
class GitUp
|
5
5
|
def run
|
6
|
-
|
6
|
+
command = ['git', 'fetch', '--multiple']
|
7
|
+
command << '--prune' if prune?
|
8
|
+
command += remotes
|
9
|
+
|
10
|
+
# puts command.join(" ") # TODO: implement a 'debug' config option
|
11
|
+
system(*command)
|
7
12
|
raise GitError, "`git fetch` failed" unless $? == 0
|
8
13
|
@remote_map = nil # flush cache after fetch
|
9
14
|
|
10
|
-
|
11
|
-
|
12
|
-
|
15
|
+
Grit::Git.with_timeout(0) do
|
16
|
+
with_stash do
|
17
|
+
returning_to_current_branch do
|
18
|
+
rebase_all_branches
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
13
22
|
|
14
|
-
|
15
|
-
|
23
|
+
check_bundler
|
24
|
+
rescue GitError => e
|
25
|
+
puts e.message
|
26
|
+
exit 1
|
27
|
+
end
|
16
28
|
|
17
|
-
|
29
|
+
def rebase_all_branches
|
30
|
+
col_width = branches.map { |b| b.name.length }.max + 1
|
18
31
|
|
19
|
-
|
20
|
-
|
21
|
-
next
|
22
|
-
end
|
32
|
+
branches.each do |branch|
|
33
|
+
remote = remote_map[branch.name]
|
23
34
|
|
24
|
-
|
35
|
+
print branch.name.ljust(col_width)
|
25
36
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
37
|
+
if remote.commit.sha == branch.commit.sha
|
38
|
+
puts "up to date".green
|
39
|
+
next
|
40
|
+
end
|
30
41
|
|
31
|
-
|
32
|
-
puts "fast-forwarding...".yellow
|
33
|
-
else
|
34
|
-
puts "rebasing...".yellow
|
35
|
-
end
|
42
|
+
base = merge_base(branch.name, remote.name)
|
36
43
|
|
37
|
-
|
38
|
-
|
39
|
-
|
44
|
+
if base == remote.commit.sha
|
45
|
+
puts "ahead of upstream".green
|
46
|
+
next
|
40
47
|
end
|
41
|
-
end
|
42
48
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
49
|
+
if base == branch.commit.sha
|
50
|
+
puts "fast-forwarding...".yellow
|
51
|
+
else
|
52
|
+
puts "rebasing...".yellow
|
53
|
+
end
|
54
|
+
|
55
|
+
checkout(branch.name)
|
56
|
+
rebase(remote)
|
57
|
+
end
|
47
58
|
end
|
48
59
|
|
49
60
|
def repo
|
@@ -218,8 +229,27 @@ EOS
|
|
218
229
|
config("bundler.check") == 'true' || ENV['GIT_UP_BUNDLER_CHECK'] == 'true'
|
219
230
|
end
|
220
231
|
|
232
|
+
def prune?
|
233
|
+
required_version = "1.6.6"
|
234
|
+
config_value = config("fetch.prune")
|
235
|
+
|
236
|
+
if git_version < required_version
|
237
|
+
if config_value == 'true'
|
238
|
+
puts "Warning: fetch.prune is set to 'true' but your git version doesn't seem to support it (#{git_version} < #{required_version}). Defaulting to 'false'.".yellow
|
239
|
+
end
|
240
|
+
|
241
|
+
false
|
242
|
+
else
|
243
|
+
config_value != 'false'
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
221
247
|
def config(key)
|
222
248
|
repo.config["git-up.#{key}"]
|
223
249
|
end
|
250
|
+
|
251
|
+
def git_version
|
252
|
+
`git --version`[/\d+(\.\d+)+/]
|
253
|
+
end
|
224
254
|
end
|
225
255
|
|
data/lib/git-up/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-up
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,11 +12,11 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2012-
|
15
|
+
date: 2012-04-24 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: thoughtbot-shoulda
|
19
|
-
requirement: &
|
19
|
+
requirement: &70276083994300 !ruby/object:Gem::Requirement
|
20
20
|
none: false
|
21
21
|
requirements:
|
22
22
|
- - ! '>='
|
@@ -24,10 +24,10 @@ dependencies:
|
|
24
24
|
version: '0'
|
25
25
|
type: :development
|
26
26
|
prerelease: false
|
27
|
-
version_requirements: *
|
27
|
+
version_requirements: *70276083994300
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: colored
|
30
|
-
requirement: &
|
30
|
+
requirement: &70276083993620 !ruby/object:Gem::Requirement
|
31
31
|
none: false
|
32
32
|
requirements:
|
33
33
|
- - ! '>='
|
@@ -35,10 +35,10 @@ dependencies:
|
|
35
35
|
version: '1.2'
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
|
-
version_requirements: *
|
38
|
+
version_requirements: *70276083993620
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
40
|
name: grit
|
41
|
-
requirement: &
|
41
|
+
requirement: &70276083992540 !ruby/object:Gem::Requirement
|
42
42
|
none: false
|
43
43
|
requirements:
|
44
44
|
- - ! '>='
|
@@ -46,7 +46,7 @@ dependencies:
|
|
46
46
|
version: '0'
|
47
47
|
type: :runtime
|
48
48
|
prerelease: false
|
49
|
-
version_requirements: *
|
49
|
+
version_requirements: *70276083992540
|
50
50
|
description:
|
51
51
|
email:
|
52
52
|
- aanand.prasad@gmail.com
|
@@ -81,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
81
|
version: '0'
|
82
82
|
requirements: []
|
83
83
|
rubyforge_project:
|
84
|
-
rubygems_version: 1.8.
|
84
|
+
rubygems_version: 1.8.17
|
85
85
|
signing_key:
|
86
86
|
specification_version: 3
|
87
87
|
summary: git command to fetch and rebase all branches
|