vendorificator 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +8 -8
  2. data/.travis.yml +1 -1
  3. data/CHANGELOG.md +8 -0
  4. data/Gemfile +0 -1
  5. data/LICENSE +2 -2
  6. data/Rakefile +1 -1
  7. data/cucumber.yml +1 -1
  8. data/features/download.feature +1 -0
  9. data/features/edgecases.feature +25 -0
  10. data/features/fixtures/git/Makefile +35 -0
  11. data/features/fixtures/git/remote.1/HEAD +1 -0
  12. data/features/fixtures/git/remote.1/config +10 -0
  13. data/features/fixtures/git/remote.1/description +1 -0
  14. data/features/fixtures/git/remote.1/hooks/applypatch-msg.sample +15 -0
  15. data/features/fixtures/git/remote.1/hooks/commit-msg.sample +24 -0
  16. data/features/fixtures/git/remote.1/hooks/post-update.sample +8 -0
  17. data/features/fixtures/git/remote.1/hooks/pre-applypatch.sample +14 -0
  18. data/features/fixtures/git/remote.1/hooks/pre-commit.sample +49 -0
  19. data/features/fixtures/git/remote.1/hooks/pre-push.sample +54 -0
  20. data/features/fixtures/git/remote.1/hooks/pre-rebase.sample +169 -0
  21. data/features/fixtures/git/remote.1/hooks/prepare-commit-msg.sample +36 -0
  22. data/features/fixtures/git/remote.1/hooks/update.sample +128 -0
  23. data/features/fixtures/git/remote.1/info/exclude +6 -0
  24. data/features/fixtures/git/remote.1/info/refs +8 -0
  25. data/features/fixtures/git/remote.1/objects/info/packs +2 -0
  26. data/features/fixtures/git/remote.1/objects/pack/pack-bb534073bd2c3b64a83cf0373085658268d94be9.idx +0 -0
  27. data/features/fixtures/git/remote.1/objects/pack/pack-bb534073bd2c3b64a83cf0373085658268d94be9.pack +0 -0
  28. data/features/fixtures/git/remote.1/packed-refs +9 -0
  29. data/features/fixtures/git/remote.1/refs/heads/.sentinel +0 -0
  30. data/features/fixtures/git/remote.1/refs/tags/.sentinel +0 -0
  31. data/features/fixtures/git/remote.1.vendor.rb +5 -0
  32. data/features/fixtures/git/remote.2/HEAD +1 -0
  33. data/features/fixtures/git/remote.2/config +10 -0
  34. data/features/fixtures/git/remote.2/description +1 -0
  35. data/features/fixtures/git/remote.2/hooks/applypatch-msg.sample +15 -0
  36. data/features/fixtures/git/remote.2/hooks/commit-msg.sample +24 -0
  37. data/features/fixtures/git/remote.2/hooks/post-update.sample +8 -0
  38. data/features/fixtures/git/remote.2/hooks/pre-applypatch.sample +14 -0
  39. data/features/fixtures/git/remote.2/hooks/pre-commit.sample +49 -0
  40. data/features/fixtures/git/remote.2/hooks/pre-push.sample +54 -0
  41. data/features/fixtures/git/remote.2/hooks/pre-rebase.sample +169 -0
  42. data/features/fixtures/git/remote.2/hooks/prepare-commit-msg.sample +36 -0
  43. data/features/fixtures/git/remote.2/hooks/update.sample +128 -0
  44. data/features/fixtures/git/remote.2/info/exclude +6 -0
  45. data/features/fixtures/git/remote.2/info/refs +14 -0
  46. data/features/fixtures/git/remote.2/objects/info/packs +2 -0
  47. data/features/fixtures/git/remote.2/objects/pack/pack-f9df9e80fe02b2e846c4ba5444b359121a8bcce6.idx +0 -0
  48. data/features/fixtures/git/remote.2/objects/pack/pack-f9df9e80fe02b2e846c4ba5444b359121a8bcce6.pack +0 -0
  49. data/features/fixtures/git/remote.2/packed-refs +15 -0
  50. data/features/fixtures/git/remote.2/refs/heads/.sentinel +0 -0
  51. data/features/fixtures/git/remote.2/refs/tags/.sentinel +0 -0
  52. data/features/fixtures/git/remote.2.vendor.rb +5 -0
  53. data/features/fixtures/git/testrepo/info/refs +2 -0
  54. data/features/fixtures/git/testrepo/objects/info/packs +1 -1
  55. data/features/fixtures/git/testrepo/objects/pack/pack-3a82989e3c58110681fd5713baa113ffc1176225.idx +0 -0
  56. data/features/fixtures/git/testrepo/objects/pack/{pack-46f7621b6a6b9b1c22dd15c08d457dfedf76e55f.pack → pack-3a82989e3c58110681fd5713baa113ffc1176225.pack} +0 -0
  57. data/features/fixtures/git/testrepo/packed-refs +3 -1
  58. data/features/remote.feature +43 -0
  59. data/features/step_definitions/basic.rb +23 -4
  60. data/lib/vendorificator/environment.rb +7 -6
  61. data/lib/vendorificator/segment/vendor.rb +2 -0
  62. data/lib/vendorificator/segment.rb +15 -16
  63. data/lib/vendorificator/vendor/download.rb +9 -3
  64. data/lib/vendorificator/vendor.rb +1 -0
  65. data/lib/vendorificator/version.rb +1 -1
  66. data/spec/vendorificator/environment_spec.rb +10 -9
  67. data/vendorificator.gemspec +1 -0
  68. metadata +96 -11
  69. data/features/fixtures/git/testrepo/objects/53/ac1a96882e666cee31504179abc21eac522f8d +0 -2
  70. data/features/fixtures/git/testrepo/objects/pack/pack-46f7621b6a6b9b1c22dd15c08d457dfedf76e55f.idx +0 -0
  71. data/features/fixtures/git/testrepo/refs/tags/email-v0 +0 -1
@@ -0,0 +1,128 @@
1
+ #!/bin/sh
2
+ #
3
+ # An example hook script to blocks unannotated tags from entering.
4
+ # Called by "git receive-pack" with arguments: refname sha1-old sha1-new
5
+ #
6
+ # To enable this hook, rename this file to "update".
7
+ #
8
+ # Config
9
+ # ------
10
+ # hooks.allowunannotated
11
+ # This boolean sets whether unannotated tags will be allowed into the
12
+ # repository. By default they won't be.
13
+ # hooks.allowdeletetag
14
+ # This boolean sets whether deleting tags will be allowed in the
15
+ # repository. By default they won't be.
16
+ # hooks.allowmodifytag
17
+ # This boolean sets whether a tag may be modified after creation. By default
18
+ # it won't be.
19
+ # hooks.allowdeletebranch
20
+ # This boolean sets whether deleting branches will be allowed in the
21
+ # repository. By default they won't be.
22
+ # hooks.denycreatebranch
23
+ # This boolean sets whether remotely creating branches will be denied
24
+ # in the repository. By default this is allowed.
25
+ #
26
+
27
+ # --- Command line
28
+ refname="$1"
29
+ oldrev="$2"
30
+ newrev="$3"
31
+
32
+ # --- Safety check
33
+ if [ -z "$GIT_DIR" ]; then
34
+ echo "Don't run this script from the command line." >&2
35
+ echo " (if you want, you could supply GIT_DIR then run" >&2
36
+ echo " $0 <ref> <oldrev> <newrev>)" >&2
37
+ exit 1
38
+ fi
39
+
40
+ if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
41
+ echo "usage: $0 <ref> <oldrev> <newrev>" >&2
42
+ exit 1
43
+ fi
44
+
45
+ # --- Config
46
+ allowunannotated=$(git config --bool hooks.allowunannotated)
47
+ allowdeletebranch=$(git config --bool hooks.allowdeletebranch)
48
+ denycreatebranch=$(git config --bool hooks.denycreatebranch)
49
+ allowdeletetag=$(git config --bool hooks.allowdeletetag)
50
+ allowmodifytag=$(git config --bool hooks.allowmodifytag)
51
+
52
+ # check for no description
53
+ projectdesc=$(sed -e '1q' "$GIT_DIR/description")
54
+ case "$projectdesc" in
55
+ "Unnamed repository"* | "")
56
+ echo "*** Project description file hasn't been set" >&2
57
+ exit 1
58
+ ;;
59
+ esac
60
+
61
+ # --- Check types
62
+ # if $newrev is 0000...0000, it's a commit to delete a ref.
63
+ zero="0000000000000000000000000000000000000000"
64
+ if [ "$newrev" = "$zero" ]; then
65
+ newrev_type=delete
66
+ else
67
+ newrev_type=$(git cat-file -t $newrev)
68
+ fi
69
+
70
+ case "$refname","$newrev_type" in
71
+ refs/tags/*,commit)
72
+ # un-annotated tag
73
+ short_refname=${refname##refs/tags/}
74
+ if [ "$allowunannotated" != "true" ]; then
75
+ echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2
76
+ echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2
77
+ exit 1
78
+ fi
79
+ ;;
80
+ refs/tags/*,delete)
81
+ # delete tag
82
+ if [ "$allowdeletetag" != "true" ]; then
83
+ echo "*** Deleting a tag is not allowed in this repository" >&2
84
+ exit 1
85
+ fi
86
+ ;;
87
+ refs/tags/*,tag)
88
+ # annotated tag
89
+ if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1
90
+ then
91
+ echo "*** Tag '$refname' already exists." >&2
92
+ echo "*** Modifying a tag is not allowed in this repository." >&2
93
+ exit 1
94
+ fi
95
+ ;;
96
+ refs/heads/*,commit)
97
+ # branch
98
+ if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then
99
+ echo "*** Creating a branch is not allowed in this repository" >&2
100
+ exit 1
101
+ fi
102
+ ;;
103
+ refs/heads/*,delete)
104
+ # delete branch
105
+ if [ "$allowdeletebranch" != "true" ]; then
106
+ echo "*** Deleting a branch is not allowed in this repository" >&2
107
+ exit 1
108
+ fi
109
+ ;;
110
+ refs/remotes/*,commit)
111
+ # tracking branch
112
+ ;;
113
+ refs/remotes/*,delete)
114
+ # delete tracking branch
115
+ if [ "$allowdeletebranch" != "true" ]; then
116
+ echo "*** Deleting a tracking branch is not allowed in this repository" >&2
117
+ exit 1
118
+ fi
119
+ ;;
120
+ *)
121
+ # Anything else (is there anything else?)
122
+ echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2
123
+ exit 1
124
+ ;;
125
+ esac
126
+
127
+ # --- Finished
128
+ exit 0
@@ -0,0 +1,6 @@
1
+ # git ls-files --others --exclude-from=.git/info/exclude
2
+ # Lines that start with '#' are comments.
3
+ # For a project mostly in C, the following would be a good set of
4
+ # exclude patterns (uncomment them if you want to use them):
5
+ # *.[oa]
6
+ # *~
@@ -0,0 +1,14 @@
1
+ 978854b42893964cd861fa3a606b9bd1effcc5ed refs/heads/master
2
+ cef71af0c9e5a71f6c4a2db360147b00ec0faef4 refs/heads/vendor/example.html
3
+ d6dfe467247ecb8fc1efdff47270c1ca9aebc0d2 refs/heads/vendor/stub
4
+ 9caaa083a2a3de2fddc0cc5dc841041ff90ee626 refs/notes/vendor
5
+ 8fa42dfde3bf120afbedb65758115c40077823f8 refs/remotes/origin/HEAD
6
+ 8fa42dfde3bf120afbedb65758115c40077823f8 refs/remotes/origin/master
7
+ cef71af0c9e5a71f6c4a2db360147b00ec0faef4 refs/remotes/origin/vendor/example.html
8
+ cfd7a7f8c5d25a3113bb4e2dc13cad1bf59f1fe5 refs/remotes/origin/vendor/stub
9
+ b63fd7b7034f54c83f98f0eb607166883840b15b refs/tags/vendor/example.html/0
10
+ cef71af0c9e5a71f6c4a2db360147b00ec0faef4 refs/tags/vendor/example.html/0^{}
11
+ e8e7b1b95249fbf213de8a300957322480c400d5 refs/tags/vendor/stub/1
12
+ cfd7a7f8c5d25a3113bb4e2dc13cad1bf59f1fe5 refs/tags/vendor/stub/1^{}
13
+ ca5ae665ed9b67e731dc5c281dac5c28c46f3fff refs/tags/vendor/stub/2
14
+ d6dfe467247ecb8fc1efdff47270c1ca9aebc0d2 refs/tags/vendor/stub/2^{}
@@ -0,0 +1,2 @@
1
+ P pack-f9df9e80fe02b2e846c4ba5444b359121a8bcce6.pack
2
+
@@ -0,0 +1,15 @@
1
+ # pack-refs with: peeled fully-peeled
2
+ 978854b42893964cd861fa3a606b9bd1effcc5ed refs/heads/master
3
+ cef71af0c9e5a71f6c4a2db360147b00ec0faef4 refs/heads/vendor/example.html
4
+ d6dfe467247ecb8fc1efdff47270c1ca9aebc0d2 refs/heads/vendor/stub
5
+ 9caaa083a2a3de2fddc0cc5dc841041ff90ee626 refs/notes/vendor
6
+ 8fa42dfde3bf120afbedb65758115c40077823f8 refs/remotes/origin/HEAD
7
+ 8fa42dfde3bf120afbedb65758115c40077823f8 refs/remotes/origin/master
8
+ cef71af0c9e5a71f6c4a2db360147b00ec0faef4 refs/remotes/origin/vendor/example.html
9
+ cfd7a7f8c5d25a3113bb4e2dc13cad1bf59f1fe5 refs/remotes/origin/vendor/stub
10
+ b63fd7b7034f54c83f98f0eb607166883840b15b refs/tags/vendor/example.html/0
11
+ ^cef71af0c9e5a71f6c4a2db360147b00ec0faef4
12
+ e8e7b1b95249fbf213de8a300957322480c400d5 refs/tags/vendor/stub/1
13
+ ^cfd7a7f8c5d25a3113bb4e2dc13cad1bf59f1fe5
14
+ ca5ae665ed9b67e731dc5c281dac5c28c46f3fff refs/tags/vendor/stub/2
15
+ ^d6dfe467247ecb8fc1efdff47270c1ca9aebc0d2
@@ -0,0 +1,5 @@
1
+ download 'example.html', version: 0, url: 'http://www.example.com/'
2
+
3
+ vendor 'stub', version: 2 do
4
+ File.write('VERSION', '2')
5
+ end
@@ -3,3 +3,5 @@
3
3
  10e9ac58c77bc229d8c59a5b4eb7422916453148 refs/heads/master
4
4
  ecbfa229ba5f11c05b18bcc4f7c32b8f25d63f8c refs/heads/topic/green
5
5
  ecbfa229ba5f11c05b18bcc4f7c32b8f25d63f8c refs/heads/topic/pink
6
+ 53ac1a96882e666cee31504179abc21eac522f8d refs/tags/email-v0
7
+ f81247bde4ef7a1c7d280140cc0bcf0b8221a51f refs/tags/email-v0^{}
@@ -1,2 +1,2 @@
1
- P pack-46f7621b6a6b9b1c22dd15c08d457dfedf76e55f.pack
1
+ P pack-3a82989e3c58110681fd5713baa113ffc1176225.pack
2
2
 
@@ -1,6 +1,8 @@
1
- # pack-refs with: peeled
1
+ # pack-refs with: peeled fully-peeled
2
2
  69389e336277bd81f9af75a565cc511eb6fb497f refs/heads/blue
3
3
  0989414c2aa7b529d3c9ede7ca4ccd940c77efe4 refs/heads/email
4
4
  10e9ac58c77bc229d8c59a5b4eb7422916453148 refs/heads/master
5
5
  ecbfa229ba5f11c05b18bcc4f7c32b8f25d63f8c refs/heads/topic/green
6
6
  ecbfa229ba5f11c05b18bcc4f7c32b8f25d63f8c refs/heads/topic/pink
7
+ 53ac1a96882e666cee31504179abc21eac522f8d refs/tags/email-v0
8
+ ^f81247bde4ef7a1c7d280140cc0bcf0b8221a51f
@@ -0,0 +1,43 @@
1
+ Feature: collaboration over a remote repository
2
+
3
+ Scenario: pulling from a remote repo that somebody has updated
4
+ Given a repository cloned from "remote.1"
5
+ Then a file named "vendor/example.html" should exist
6
+ And the file "vendor/stub/VERSION" should contain "1"
7
+ And tag "vendor/example.html/0" exists
8
+ And tag "vendor/stub/1" exists
9
+ And tag "vendor/stub/2" does not exist
10
+ And branch "vendor/example.html" does not exist
11
+ And branch "vendor/stub" does not exist
12
+
13
+ When I run `git pull --tags`
14
+ Then tag "vendor/example.html/0" exists
15
+ And tag "vendor/stub/1" exists
16
+ And tag "vendor/stub/2" does not exist
17
+ And branch "vendor/example.html" does not exist
18
+ And branch "vendor/stub" does not exist
19
+
20
+ When I run vendor command "pull"
21
+ Then tag "vendor/example.html/0" exists
22
+ And tag "vendor/stub/1" exists
23
+ And tag "vendor/stub/2" does not exist
24
+ And branch "vendor/example.html" exists
25
+ And branch "vendor/stub" exists
26
+ And the following has been conjured:
27
+ | Name | example.html | stub |
28
+ | Version | 0 | 1 |
29
+ | With file | | VERSION |
30
+
31
+ When remote repository is updated from "remote.2"
32
+ And I run vendor command "pull"
33
+ Then tag "vendor/stub/2" exists
34
+ And the file "vendor/stub/VERSION" should contain "1"
35
+ And the following has been conjured:
36
+ | Name | example.html | stub |
37
+ | Version | 0 | 1 |
38
+ | With file | | VERSION |
39
+ And the last vendor output should match /updated\s+stub/
40
+ And the last vendor output should match /unchanged\s+example\.html/
41
+
42
+ When I run `git pull origin master`
43
+ Then the file "vendor/stub/VERSION" should contain "2"
@@ -6,13 +6,17 @@ When /^nothing happens$/ do
6
6
  nil # NOP
7
7
  end
8
8
 
9
+ # Configure Git username & email to unclutter console output
10
+ def configure_git
11
+ run_simple 'git config user.name Cucumber'
12
+ run_simple 'git config user.email cucumber@`hostname --fqdn`'
13
+ end
14
+
9
15
  Given /^a repository with following Vendorfile:$/ do |vendorfile_contents|
10
16
  create_dir 'working-repository'
11
17
  cd 'working-repository'
12
18
  run_simple 'git init'
13
- # Configure Git username & email to unclutter console output
14
- run_simple 'git config user.name Cucumber'
15
- run_simple 'git config user.email cucumber@`hostname --fqdn`'
19
+ configure_git
16
20
  write_file('README', 'Lorem ipsum dolor sit amet')
17
21
  write_file('Vendorfile', vendorfile_contents)
18
22
  run_simple 'git add .'
@@ -23,13 +27,28 @@ Given /^a remote repository$/ do
23
27
  create_dir '../remote-repository'
24
28
  cd '../remote-repository'
25
29
  run_simple 'git init --bare'
26
- # Configure Git username & email to unclutter console output
30
+ configure_git
27
31
  run_simple 'git config user.name Cucumber'
28
32
  run_simple 'git config user.email cucumber@`hostname --fqdn`'
29
33
  cd '../working-repository'
30
34
  run_simple 'git remote add origin ../remote-repository'
31
35
  end
32
36
 
37
+ Given(/^a repository cloned from "(.*)"$/) do |fixture|
38
+ repo_path = File.join(ENV['FIXTURES_DIR'], 'git', fixture)
39
+ run_simple "git clone --mirror \"#{repo_path}\" remote-repository"
40
+ run_simple "git clone remote-repository working-repository"
41
+ cd 'working-repository'
42
+ configure_git
43
+ end
44
+
45
+ When(/^remote repository is updated from "(.*)"$/) do |fixture|
46
+ cd '../remote-repository'
47
+ repo_path = File.join(ENV['FIXTURES_DIR'], 'git', fixture)
48
+ run_simple "git fetch \"#{repo_path}\" 'refs/*:refs/*'"
49
+ cd '../working-repository'
50
+ end
51
+
33
52
  When /^I set the fake mode variable$/ do
34
53
  Dir.chdir(current_dir) do
35
54
  MiniGit::Capturing.git :config, 'vendorificator.stub', 'true'
@@ -72,10 +72,11 @@ module Vendorificator
72
72
  def pull(remote, options={})
73
73
  raise RuntimeError, "Unknown remote #{remote}" unless remotes.include?(remote)
74
74
 
75
- git.fetch(remote)
76
- git.fetch({:tags => true}, remote)
77
75
  begin
78
- git.fetch(remote, 'refs/notes/vendor:refs/notes/vendor')
76
+ git.fetch({:quiet => true}, remote,
77
+ "refs/heads/#{config[:branch_prefix]}/*:refs/remotes/origin/#{config[:branch_prefix]}/*",
78
+ 'refs/tags/*:refs/tags/*',
79
+ 'refs/notes/vendor:refs/notes/vendor')
79
80
  rescue MiniGit::GitError # ignore
80
81
  end
81
82
 
@@ -91,10 +92,10 @@ module Vendorificator
91
92
  theirs = remote_branches[mod.branch_name]
92
93
  if theirs
93
94
  if not ours
94
- say_status :default, 'new', mod.branch_name, :yellow
95
- git.branch({:track => true}, mod.branch_name, theirs) unless options[:dry_run]
95
+ say_status :default, 'new', mod.name, :yellow
96
+ git.branch({:track => true, :quiet => true}, mod.branch_name, "#{remote}/#{mod.branch_name}") unless options[:dry_run]
96
97
  elsif ours == theirs
97
- say_status :default, 'unchanged', mod.branch_name
98
+ say_status :default, 'unchanged', mod.name
98
99
  elsif fast_forwardable?(theirs, ours)
99
100
  say_status :default, 'updated', mod.name, :yellow
100
101
  mod.fast_forward theirs unless options[:dry_run]
@@ -59,6 +59,8 @@ module Vendorificator
59
59
  tmpdir_entries = (Dir.entries(tmpdir) - %w'. ..').
60
60
  map { |e| File.join(tmpdir, e) }
61
61
  FileUtils.mv tmpdir_entries, work_dir
62
+
63
+ @vendor.after_conjure!
62
64
  commit_and_annotate(options[:metadata] || {})
63
65
  ensure
64
66
  @git = nil
@@ -6,7 +6,10 @@ module Vendorificator
6
6
  end
7
7
 
8
8
  def fast_forward(branch)
9
- in_branch { |tmpgit| tmpgit.merge({:ff_only => true}, branch) }
9
+ in_branch do |tmpgit|
10
+ tmpgit.checkout(:quiet => true)
11
+ tmpgit.merge({:ff_only => true, :quiet => true}, branch)
12
+ end
10
13
  end
11
14
 
12
15
  def status
@@ -117,7 +120,7 @@ module Vendorificator
117
120
  return if config.fake_mode?
118
121
 
119
122
  git.capturing.add work_dir, *@vendor.git_add_extra_paths
120
- git.capturing.commit :m => @vendor.conjure_commit_message
123
+ git.capturing.commit :m => @vendor.conjure_commit_message, :allow_empty => true
121
124
  git.capturing.notes({:ref => 'vendor'}, 'add', {:m => conjure_note(environment_metadata)}, 'HEAD')
122
125
  git.capturing.tag( { :a => true, :m => tag_message }, tag_name )
123
126
  say_status :default, :tag, tag_name
@@ -140,7 +143,6 @@ module Vendorificator
140
143
  Dir.mktmpdir do |tmpdir|
141
144
  tmpgit = create_temp_git_repo(branch, options, tmpdir)
142
145
  fetch_repo_data tmpgit
143
- repo_cleanup tmpgit if options[:clean] || !branch_exists?(branch)
144
146
 
145
147
  Dir.chdir(tmpdir){ yield tmpgit }
146
148
 
@@ -149,24 +151,21 @@ module Vendorificator
149
151
  end
150
152
 
151
153
  def create_temp_git_repo(branch, options, dir)
152
- clone_opts = {shared: true, no_checkout: true}
154
+ clone_opts = {shared: true, no_checkout: true, quiet: true}
153
155
  clone_opts[:branch] = branch if branch_exists? branch
154
- say { MiniGit::Capturing.git :clone, clone_opts, git.git_dir, dir }
156
+ MiniGit.git(:clone, clone_opts, git.git_dir, dir)
155
157
 
156
158
  tmpgit = MiniGit.new(dir)
157
159
  unless branch_exists? branch
158
- say { tmpgit.capturing.checkout({orphan: true}, branch) }
160
+ tmpgit.capturing.checkout({quiet: true}, {orphan: true}, branch)
161
+ tmpgit.capturing.rm({ :r => true, :f => true, :q => true, :ignore_unmatch => true }, '.')
159
162
  end
160
163
 
161
164
  tmpgit
162
165
  end
163
166
 
164
- def repo_cleanup(tmpgit)
165
- tmpgit.rm({ :r => true, :f => true, :q => true, :ignore_unmatch => true }, '.')
166
- end
167
-
168
167
  def fetch_repo_data(tmpgit)
169
- tmpgit.fetch git.git_dir, "refs/notes/vendor:refs/notes/vendor" if notes_exist?
168
+ tmpgit.fetch({quiet: true}, git.git_dir, "refs/notes/vendor:refs/notes/vendor") if notes_exist?
170
169
  end
171
170
 
172
171
  def propagate_repo_data_to_original(branch, clone_dir)
@@ -186,11 +185,10 @@ module Vendorificator
186
185
  #
187
186
  # Returns nothing.
188
187
  def fetch_back_from_temporary_clone(branch, clone_dir)
189
- git.fetch clone_dir
190
- git.fetch({tags: true}, clone_dir)
191
- git.fetch clone_dir,
188
+ git.fetch({quiet: true}, clone_dir,
192
189
  "refs/heads/#{branch}:refs/heads/#{branch}",
193
- "refs/notes/vendor:refs/notes/vendor"
190
+ "refs/tags/*:refs/tags/*",
191
+ "refs/notes/vendor:refs/notes/vendor")
194
192
  end
195
193
 
196
194
  # Private: Copies the conjured vendor files back to main repo, instead of
@@ -317,6 +315,7 @@ module Vendorificator
317
315
  end
318
316
 
319
317
  def merged_base
318
+ return nil if !head
320
319
  return @merged_base if defined? @merged_base
321
320
  base = git.capturing.merge_base(head, 'HEAD').strip
322
321
  @merged_base = base.empty? ? nil : base
@@ -347,7 +346,7 @@ module Vendorificator
347
346
  #
348
347
  # Returns true/false.
349
348
  def branch_exists?(branch = branch_name)
350
- git.capturing.rev_parse({:verify => true}, "refs/heads/#{branch}")
349
+ git.capturing.rev_parse({:verify => true, :quiet => true}, "refs/heads/#{branch}")
351
350
  true
352
351
  rescue MiniGit::GitError
353
352
  false
@@ -16,14 +16,20 @@ module Vendorificator
16
16
 
17
17
  def conjure!
18
18
  say_status :default, :download, url
19
- File.open name, 'w' do |outf|
19
+ File.open 'content', 'w' do |outf|
20
20
  outf.write( open(url).read )
21
21
  end
22
- @conjured_checksum = Digest::SHA256.file(name).hexdigest
23
- @conjured_filesize = File.size(name)
22
+ @conjured_checksum = Digest::SHA256.file('content').hexdigest
23
+ @conjured_filesize = File.size('content')
24
24
  add_download_metadata
25
25
  end
26
26
 
27
+ def after_conjure!
28
+ FileUtils.mv File.join(work_dir, 'content'), work_dir+'.content'
29
+ Dir.rmdir work_dir
30
+ FileUtils.mv work_dir+'.content', work_dir
31
+ end
32
+
27
33
  def upstream_version
28
34
  conjured_checksum || Digest::SHA256.hexdigest( open(url).read )
29
35
  end
@@ -66,6 +66,7 @@ module Vendorificator
66
66
  # Hook points
67
67
  def git_add_extra_paths ; [] ; end
68
68
  def before_conjure! ; end
69
+ def after_conjure! ; end
69
70
  def compute_dependencies! ; end
70
71
  def upstream_version ; end
71
72
 
@@ -1,3 +1,3 @@
1
1
  module Vendorificator
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.3"
3
3
  end
@@ -43,19 +43,21 @@ module Vendorificator
43
43
 
44
44
  describe '#pull' do
45
45
  before do
46
- environment.git.expects(:fetch).with('origin')
47
- environment.git.expects(:fetch).with({:tags => true}, 'origin')
48
- @git_fetch_notes = environment.git.expects(:fetch).with('origin', 'refs/notes/vendor:refs/notes/vendor')
46
+ @fetch = environment.git.expects(:fetch).with({:quiet => true}, 'origin',
47
+ 'refs/heads/vendor/*:refs/remotes/origin/vendor/*',
48
+ 'refs/tags/*:refs/tags/*',
49
+ 'refs/notes/vendor:refs/notes/vendor')
49
50
  environment.git.capturing.stubs(:show_ref).returns("602315 refs/remotes/origin/vendor/test\n")
50
51
  end
51
52
 
52
53
  it "creates a branch if it doesn't exist" do
53
54
  environment.segments << stub(
54
- :branch_name => 'vendor/test', :head => nil,
55
- :compute_dependencies! => nil
56
- )
55
+ :name => 'test',
56
+ :branch_name => 'vendor/test',
57
+ :head => nil,
58
+ :compute_dependencies! => nil)
57
59
 
58
- environment.git.expects(:branch).with({:track => true}, 'vendor/test', '602315')
60
+ environment.git.expects(:branch).with({:track => true, :quiet => true}, 'vendor/test', 'origin/vendor/test')
59
61
 
60
62
  environment.pull('origin')
61
63
  end
@@ -71,8 +73,7 @@ module Vendorificator
71
73
  end
72
74
 
73
75
  it "handles git error on fetching empty notes" do
74
- @git_fetch_notes.raises(MiniGit::GitError)
75
-
76
+ @fetch.raises(MiniGit::GitError)
76
77
  environment.pull('origin')
77
78
  end
78
79
  end
@@ -10,6 +10,7 @@ Gem::Specification.new do |gem|
10
10
  gem.description = "Vendor everything. Stay sane."
11
11
  gem.summary = "Integrate third-party vendor modules into your git repository"
12
12
  gem.homepage = "https://github.com/3ofcoins/vendorificator/"
13
+ gem.license = "MIT"
13
14
 
14
15
  gem.files = `git ls-files`.split($\)
15
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }