gitty 0.3.6 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/assets/hooks/auto-submodules +18 -7
  2. metadata +2 -2
@@ -8,7 +8,7 @@
8
8
  # - If a submodule has been removed from the branch you move to, it alerts you
9
9
  # - If a submodule has been added on the branch you move to, it alerts you
10
10
  # - Otherwise, it checks out the revision for you
11
- # version: 0.1
11
+ # version: 0.2
12
12
  # targets: ["pre-rebase", "post-applypatch", "post-checkout", "post-merge"]
13
13
 
14
14
  # this is a bit of a hack: when a rebase is ran, we don't want to have the initial checkout update submodules
@@ -83,17 +83,28 @@ previous_submodules = list_submodules('HEAD@{1}')
83
83
  system("(git show '#{current_submodules[path]}' 2> /dev/null 1> /dev/null) || git fetch")
84
84
 
85
85
  current_rev = current_submodules[path]
86
- STDERR.puts("submodule is pointing to #{rev}")
87
86
  rev, ref_kind, ref = %x{git for-each-ref}.split("\n").map { |l| l.split(" ") }.detect {|l| l.first == current_rev }
88
87
 
89
88
  if ref.nil?
90
- STDERR.puts "no known branch is currently at #{current_rev}, so we had to detach your HEAD."
91
- STDERR.puts "here are some suggestions: "
92
- system("git branch --contains #{current_rev} -a | egrep -v 'no branch|HEAD' 1>&2")
93
- exit 1
89
+ system("git checkout -q #{current_rev}")
90
+ if $? == 0
91
+ STDERR.puts "Submodule HEAD was detached. The following branches contain the new HEAD:"
92
+ system("git branch --contains #{current_rev} -a | egrep -v 'no branch|HEAD' 1>&2")
93
+ exit 0
94
+ else
95
+ STDERR.puts "Couldn't update submodule."
96
+ exit $?
97
+ end
94
98
  end
95
99
  if ref.match(/^refs\/heads/)
96
- exec("git checkout '#{File.basename(ref)}'")
100
+ system("git checkout -q '#{File.basename(ref)}'")
101
+ if $? == 0
102
+ STDERR.puts "Checked out #{File.basename(ref)}"
103
+ exit 0
104
+ else
105
+ STDERR.puts "Couldn't update submodule."
106
+ exit $?
107
+ end
97
108
  end
98
109
 
99
110
  if ref.match(/^refs\/remotes/) then
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Harper
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-03-04 00:00:00 -07:00
12
+ date: 2010-03-10 00:00:00 -07:00
13
13
  default_executable: git-hook
14
14
  dependencies: []
15
15