git-multirepo 1.0.0.beta32 → 1.0.0.beta34

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82162a9cc290a3d97f8db37ee108a82d0a480e29
4
- data.tar.gz: f1b49390a52450c77dbed2125fec8e491351f44b
3
+ metadata.gz: c045eba95d5673d7f6d50df2792b88746c72a823
4
+ data.tar.gz: bf3bc7c42774720c56a5befa2d8d2282308e73e8
5
5
  SHA512:
6
- metadata.gz: 01c17b8cd7dfdb152b8e72da33e0442caa61c6245beb58e345342f6da1921fb250d33ac395d52840a4a6b2d010784e1fa2d791cc1b76d5ceec29680626cbc3be
7
- data.tar.gz: 1b1a49c8b247330283daf82ed667e04ec436f85ff69d7926b5e1ac850ac61cee290a2663b5d9e79b83fb4c0b2d4b00ab34a5331384489b938fc13b493d749d11
6
+ metadata.gz: 6c0d78aa10b2f0fa88d7b4cd0d9c55a83b00d44e54d8736ea7281753e81838218f8419ec426be2d2d1cfc74095bf440eff7c78036f1c03c5640b52b877717e54
7
+ data.tar.gz: fe699d4d22fa26656e12378319b6d47954ca9200b3c0b6938e8b10ef3cef547e463d9e47e8064d97c570fe245ad31fe89933440e98fbfb23234997790c29d1c0
data/.multirepo.lock CHANGED
@@ -2,12 +2,12 @@
2
2
  - !ruby/object:MultiRepo::LockEntry
3
3
  name: git-multirepo-dummy
4
4
  id: e27695e9-e21d-4ad1-81b8-0ed587574c38
5
- head: 111f680fd0153a35ed97febc48d118c784f0a98f
5
+ head: ff42af28013b1609f6b060d87b14d0b6414b2380
6
6
  branch: master
7
7
  - !ruby/object:MultiRepo::LockEntry
8
8
  name: git-multirepo-dummy-dep1
9
9
  id: dcb567d6-7456-494a-b7b5-adc208a87f2f
10
- head: e906c3c87cbade5837b014b48ef9922f58c94fbb
10
+ head: b64dbc542086dbbf926b330d1a70b13d3f2a6a48
11
11
  branch: master
12
12
  - !ruby/object:MultiRepo::LockEntry
13
13
  name: git-multirepo-dummy-dep2
@@ -17,5 +17,5 @@
17
17
  - !ruby/object:MultiRepo::LockEntry
18
18
  name: git-multirepo-migrations
19
19
  id: ad6472a5-7238-447f-a54e-50f50197e21e
20
- head: 841223db4851a1de7af8e22205eb7a840cc0ad38
20
+ head: 160b6a15d9bed989abbcf81d2a91cb4a226f4482
21
21
  branch: master
data/.multirepo.meta CHANGED
@@ -1,2 +1,2 @@
1
1
  --- !ruby/object:MultiRepo::MetaFile
2
- version: 1.0.0.beta32
2
+ version: 1.0.0.beta33
@@ -0,0 +1,21 @@
1
+ echo "----> Setup a new test repo"
2
+ dir_name="PreCommitHookAddTest"
3
+ rm -rf $dir_name; mkdir $dir_name; cd $dir_name
4
+ git init; git commit --allow-empty -m "Initial commit"
5
+
6
+ echo "----> Add a pre-commit hook that stages a file that doesn't currently exist in the repo"
7
+ echo "touch auto-added; git add auto-added" > .git/hooks/pre-commit
8
+ chmod +x .git/hooks/pre-commit
9
+
10
+ echo "----> Try committing a new file using the '-o' flag"
11
+ touch manually-added; git add manually-added
12
+ git commit -o -m "Commit that ran the pre-commit hook and should contain file 'auto-added'" -- manually-added
13
+
14
+ echo "----> Results (expected: working copy clean; actual: auto-added is reported as both DELETED and UNTRACKED. HEAD and working copy are the same, staging area contains ‘incorrect' state)"
15
+ git status
16
+
17
+ echo "----> Stage the file after the fact"
18
+ git add auto-added
19
+
20
+ echo "----> Notice that the working copy is now clean"
21
+ git status
Binary file
data/lib/git-multirepo.rb CHANGED
@@ -1 +1,2 @@
1
- require "multirepo/hooks/pre-commit-hook.rb"
1
+ require "multirepo/hooks/pre-commit-hook.rb"
2
+ require "multirepo/hooks/post-commit-hook.rb"
data/lib/info.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module MultiRepo
2
2
  NAME = "git-multirepo"
3
- VERSION = "1.0.0.beta32"
3
+ VERSION = "1.0.0.beta34"
4
4
  DESCRIPTION = "Track multiple Git repositories side-by-side."
5
5
  end
@@ -32,10 +32,12 @@ module MultiRepo
32
32
  def install_hooks(path)
33
33
  actual_path = path || "."
34
34
  Utils.install_hook("pre-commit", actual_path)
35
+ Utils.install_hook("post-commit", actual_path)
35
36
  end
36
37
 
37
38
  def uninstall_hooks
38
39
  FileUtils.rm_f(".git/hooks/pre-commit")
40
+ FileUtils.rm_f(".git/hooks/post-commit")
39
41
  end
40
42
 
41
43
  def update_gitconfig(path)
@@ -10,6 +10,12 @@ module MultiRepo
10
10
  ensure_in_work_tree
11
11
  ensure_multirepo_enabled
12
12
 
13
+ Console.log_step("Fetching main repo...")
14
+
15
+ main_repo = Repo.new(".")
16
+ Console.log_substep("Fetching from #{main_repo.remote('origin').url}...")
17
+ main_repo.fetch
18
+
13
19
  Console.log_step("Fetching dependencies...")
14
20
 
15
21
  ConfigFile.load_entries.each do |entry|
@@ -55,22 +55,20 @@ module MultiRepo
55
55
  end
56
56
 
57
57
  def install_hooks_step
58
- install_hooks(".")
59
- Console.log_substep("Installed git hooks in main repo")
60
-
61
- multirepo_enabled_dependencies.each do |entry|
62
- install_hooks(entry.repo.path)
63
- Console.log_substep("Installed hooks in multirepo-enabled dependency '#{entry.repo.path}'")
64
- end
58
+ perform_in_main_repo_and_dependencies("Installed git hooks") { |repo| install_hooks(repo) }
65
59
  end
66
60
 
67
61
  def update_gitconfigs_step
68
- update_gitconfig(".")
69
- Console.log_substep("Updated .git/config file")
62
+ perform_in_main_repo_and_dependencies("Updated .git/config file") { |repo| update_gitconfig(repo) }
63
+ end
64
+
65
+ def perform_in_main_repo_and_dependencies(message_prefix, &operation)
66
+ operation.call(".")
67
+ Console.log_substep("#{message_prefix} in main repo")
70
68
 
71
69
  multirepo_enabled_dependencies.each do |entry|
72
- update_gitconfig(entry.repo.path)
73
- Console.log_substep("Updated .git/config in multirepo-enabled dependency '#{entry.repo.path}'")
70
+ operation.call(entry.repo.path)
71
+ Console.log_substep("#{message_prefix} in multirepo-enabled dependency '#{entry.repo.path}'")
74
72
  end
75
73
  end
76
74
 
@@ -21,15 +21,15 @@ module MultiRepo
21
21
  end
22
22
 
23
23
  def self.entry_exists?(entry)
24
- load.any? { |e| e == entry }
24
+ load_entries.any? { |e| e == entry }
25
25
  end
26
26
 
27
27
  def self.add_entry(entry)
28
- save(load.push(entry))
28
+ save_entries(load_entries.push(entry))
29
29
  end
30
30
 
31
31
  def self.remove_entry(entry)
32
- save(load.delete_if { |e| e == entry })
32
+ save_entries(load_entries.delete_if { |e| e == entry })
33
33
  end
34
34
  end
35
35
  end
@@ -19,7 +19,10 @@ module MultiRepo
19
19
  # True fix for the -C flag issue in pre-commit hook where the status command would
20
20
  # fail to provide correct results if a pathspec was provided when performing a commit.
21
21
  # http://thread.gmane.org/gmane.comp.version-control.git/263319/focus=263323
22
- full_command = "sh -c 'unset $(git rev-parse --local-env-vars); #{full_command};'" if Config.instance.running_git_hook
22
+
23
+ if Config.instance.running_git_hook
24
+ full_command = "sh -c 'unset $(git rev-parse --local-env-vars); #{full_command};'"
25
+ end
23
26
 
24
27
  run(full_command, verbosity)
25
28
  end
@@ -0,0 +1,23 @@
1
+ require "multirepo/files/config-file"
2
+ require "multirepo/files/tracking-files"
3
+ require "multirepo/utility/utils"
4
+ require "multirepo/utility/console"
5
+
6
+ module MultiRepo
7
+ class PostCommitHook
8
+ def self.run
9
+ Config.instance.running_git_hook = true
10
+
11
+ Console.log_step("Performing post-commit operations...")
12
+
13
+ # Works around bug #91565510 (https://www.pivotaltracker.com/story/show/91565510)
14
+ TrackingFiles.stage
15
+ Console.log_info("Cleaned-up staging area")
16
+
17
+ exit 0 # Success!
18
+ rescue StandardError => e
19
+ Console.log_error("Post-commit hook failed to execute! #{e.message}")
20
+ exit 1 # Something went wrong!
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "rubygems"
4
+ require "git-multirepo"
5
+
6
+ MultiRepo::PostCommitHook.run
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-multirepo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta32
4
+ version: 1.0.0.beta34
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michaël Fortin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-02 00:00:00.000000000 Z
11
+ date: 2015-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -120,6 +120,7 @@ files:
120
120
  - README.md
121
121
  - Rakefile
122
122
  - bin/multi
123
+ - docs/bug-repros/91565510-repro.sh
123
124
  - docs/git-multirepo-cheatsheet.docx
124
125
  - git-multirepo.gemspec
125
126
  - lib/commands.rb
@@ -152,12 +153,14 @@ files:
152
153
  - lib/multirepo/git/git.rb
153
154
  - lib/multirepo/git/remote.rb
154
155
  - lib/multirepo/git/repo.rb
156
+ - lib/multirepo/hooks/post-commit-hook.rb
155
157
  - lib/multirepo/hooks/pre-commit-hook.rb
156
158
  - lib/multirepo/multirepo-exception.rb
157
159
  - lib/multirepo/utility/console.rb
158
160
  - lib/multirepo/utility/runner.rb
159
161
  - lib/multirepo/utility/utils.rb
160
162
  - resources/.gitconfig
163
+ - resources/post-commit
161
164
  - resources/pre-commit
162
165
  - spec/integration/init_spec.rb
163
166
  - spec/spec_helper.rb