git-up 0.5.5 → 0.5.7

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.
Files changed (4) hide show
  1. data/README.md +13 -1
  2. data/lib/git-up.rb +16 -10
  3. data/lib/git-up/version.rb +1 -1
  4. metadata +24 -9
data/README.md CHANGED
@@ -36,4 +36,16 @@ If you're even lazier, you can tell `git-up` to run `bundle install` for you if
36
36
 
37
37
  ### `git-up.fetch.prune [true|false]`
38
38
 
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.
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 [remove any remote tracking branches which no longer exist on the remote](http://linux.die.net/man/1/git-fetch). Set this option to `false` to disable it.
40
+
41
+ ### `git-up.fetch.all [true|false]`
42
+
43
+ Normally, `git-up` will only fetch remotes for which there is at least one local tracking branch. Setting this option will it `git-up` always fetch from all remotes, which is useful if e.g. you use a remote to push to your CI system but never check those branches out.
44
+
45
+ ### `git-up.rebase.arguments [string]`
46
+
47
+ If this option is set, its contents will be used by `git-up` as additional arguments when it calls `git rebase`. For example, setting this to `--preserve-merges` will recreate your merge commits in the rebased branch.
48
+
49
+ ### `git-up.rebase.log-hook "COMMAND"`
50
+
51
+ Runs COMMAND every time a branch is rebased or fast-forwarded, with the old head as $1 and the new head as $2. This can be used to view logs or diffs of incoming changes. For example: `'echo "changes on $1:"; git log --oneline --decorate $1..$2'`
data/lib/git-up.rb CHANGED
@@ -5,7 +5,7 @@ class GitUp
5
5
  def run
6
6
  command = ['git', 'fetch', '--multiple']
7
7
  command << '--prune' if prune?
8
- command += remotes
8
+ command += config("fetch.all") ? ['--all'] : remotes
9
9
 
10
10
  # puts command.join(" ") # TODO: implement a 'debug' config option
11
11
  system(*command)
@@ -29,6 +29,11 @@ class GitUp
29
29
  def rebase_all_branches
30
30
  col_width = branches.map { |b| b.name.length }.max + 1
31
31
 
32
+ branches.sort_by! do |b|
33
+ # perhaps add some way to customize sorting?
34
+ b.name
35
+ end
36
+
32
37
  branches.each do |branch|
33
38
  remote = remote_map[branch.name]
34
39
 
@@ -52,6 +57,7 @@ class GitUp
52
57
  puts "rebasing...".yellow
53
58
  end
54
59
 
60
+ log(branch, remote)
55
61
  checkout(branch.name)
56
62
  rebase(remote)
57
63
  end
@@ -138,10 +144,17 @@ class GitUp
138
144
  end
139
145
  end
140
146
 
147
+ def log(branch, remote)
148
+ if log_hook = config("rebase.log-hook")
149
+ system('sh', '-c', log_hook, 'git-up', branch.name, remote.name)
150
+ end
151
+ end
152
+
141
153
  def rebase(target_branch)
142
154
  current_branch = repo.head
155
+ arguments = config("rebase.arguments")
143
156
 
144
- output, err = repo.git.sh("#{Grit::Git.git_binary} rebase #{target_branch.name}")
157
+ output, err = repo.git.sh("#{Grit::Git.git_binary} rebase #{arguments} #{target_branch.name}")
145
158
 
146
159
  unless on_branch?(current_branch.name) and is_fast_forward?(current_branch, target_branch)
147
160
  raise GitError.new("Failed to rebase #{current_branch.name} onto #{target_branch.name}", output+err)
@@ -243,14 +256,7 @@ EOS
243
256
 
244
257
  def change_count
245
258
  @change_count ||= begin
246
- diff_status = repo.status
247
- actual_status = repo.git.status(:porcelain => true).split("\n").map {|l| l[3..-1]}
248
-
249
- added = diff_status.added.select { |(x,y)| actual_status.include? x }
250
- changed = diff_status.changed.select { |(x,y)| actual_status.include? x }
251
- deleted = diff_status.deleted.select { |(x,y)| actual_status.include? x }
252
-
253
- added.length + changed.length + deleted.length
259
+ repo.git.status(:porcelain => true, :'untracked-files' => 'no').split("\n").count
254
260
  end
255
261
  end
256
262
 
@@ -1,3 +1,3 @@
1
1
  class GitUp
2
- VERSION = "0.5.5"
2
+ VERSION = "0.5.7"
3
3
  end
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.5
4
+ version: 0.5.7
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-05-03 00:00:00.000000000 Z
15
+ date: 2012-09-17 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: thoughtbot-shoulda
19
- requirement: &70332208938180 !ruby/object:Gem::Requirement
19
+ requirement: !ruby/object:Gem::Requirement
20
20
  none: false
21
21
  requirements:
22
22
  - - ! '>='
@@ -24,10 +24,15 @@ dependencies:
24
24
  version: '0'
25
25
  type: :development
26
26
  prerelease: false
27
- version_requirements: *70332208938180
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
28
33
  - !ruby/object:Gem::Dependency
29
34
  name: colored
30
- requirement: &70332208937240 !ruby/object:Gem::Requirement
35
+ requirement: !ruby/object:Gem::Requirement
31
36
  none: false
32
37
  requirements:
33
38
  - - ! '>='
@@ -35,10 +40,15 @@ dependencies:
35
40
  version: '1.2'
36
41
  type: :runtime
37
42
  prerelease: false
38
- version_requirements: *70332208937240
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '1.2'
39
49
  - !ruby/object:Gem::Dependency
40
50
  name: grit
41
- requirement: &70332208936000 !ruby/object:Gem::Requirement
51
+ requirement: !ruby/object:Gem::Requirement
42
52
  none: false
43
53
  requirements:
44
54
  - - ! '>='
@@ -46,7 +56,12 @@ dependencies:
46
56
  version: '0'
47
57
  type: :runtime
48
58
  prerelease: false
49
- version_requirements: *70332208936000
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
50
65
  description:
51
66
  email:
52
67
  - aanand.prasad@gmail.com
@@ -81,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
96
  version: '0'
82
97
  requirements: []
83
98
  rubyforge_project:
84
- rubygems_version: 1.8.17
99
+ rubygems_version: 1.8.23
85
100
  signing_key:
86
101
  specification_version: 3
87
102
  summary: git command to fetch and rebase all branches