vendorificator 0.1.1 → 0.2.0

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 (38) hide show
  1. data/.travis.yml +5 -2
  2. data/Gemfile +0 -1
  3. data/README.md +9 -0
  4. data/Rakefile +7 -1
  5. data/features/chef_cookbook.feature +4 -6
  6. data/features/deprecated.feature +4 -4
  7. data/features/git.feature +41 -2
  8. data/features/needed.feature +8 -7
  9. data/features/smoke.feature +7 -5
  10. data/features/status.feature +15 -15
  11. data/features/step_definitions/aruba_ext.rb +11 -0
  12. data/features/step_definitions/basic.rb +16 -43
  13. data/features/step_definitions/git.rb +11 -11
  14. data/features/step_definitions/vendorificator.rb +4 -6
  15. data/features/support/aruba_ext.rb +23 -0
  16. data/features/support/env.rb +13 -20
  17. data/features/support/minigit.rb +37 -0
  18. data/features/tarball.feature +7 -7
  19. data/features/tarball_edit.feature +1 -1
  20. data/features/vendor.feature +2 -2
  21. data/lib/vendorificator/cli.rb +36 -61
  22. data/lib/vendorificator/config.rb +5 -42
  23. data/lib/vendorificator/environment.rb +111 -0
  24. data/lib/vendorificator/hooks/chef_cookbook.rb +59 -23
  25. data/lib/vendorificator/vendor/archive.rb +2 -2
  26. data/lib/vendorificator/vendor/chef_cookbook.rb +2 -2
  27. data/lib/vendorificator/vendor/download.rb +44 -0
  28. data/lib/vendorificator/vendor/git.rb +9 -11
  29. data/lib/vendorificator/vendor.rb +105 -48
  30. data/lib/vendorificator/version.rb +1 -1
  31. data/lib/vendorificator.rb +2 -0
  32. data/spec/spec_helper.rb +1 -0
  33. data/spec/vendorificator/vendor_spec.rb +15 -7
  34. data/vendorificator.gemspec +4 -4
  35. metadata +24 -21
  36. data/features/support/world_git.rb +0 -40
  37. data/features/support/world_runs.rb +0 -93
  38. data/lib/vendorificator/repo.rb +0 -69
@@ -1,69 +0,0 @@
1
- require 'grit'
2
-
3
- module Vendorificator
4
- class Repo < Grit::Repo
5
- # True if repository doesn't contain uncommitted changes.
6
- def clean?
7
- # copy code from http://stackoverflow.com/a/3879077/16390
8
- git.native :update_index, {}, '-q', '--ignore-submodules', '--refresh'
9
- git.native :diff_files, {:raise => true}, '--quiet', '--ignore-submodules', '--'
10
- git.native :diff_index, {:raise => true}, '--cached', '--quiet', 'HEAD', '--ignore-submodules', '--'
11
- true
12
- rescue Grit::Git::CommandFailed
13
- false
14
- end
15
-
16
- # Update vendor branches & tags from an upstream repository
17
- def pull(remote, options={})
18
- raise RuntimeError, "Unknown remote #{remote}" unless remote_list.include?(remote)
19
-
20
- git.fetch({}, remote)
21
- git.fetch({:tags => true}, remote)
22
-
23
- ref_rx = /^#{Regexp.quote(remote)}\//
24
- remote_branches = Hash[remotes.map{|r| [$',r] if r.name =~ ref_rx }.compact]
25
-
26
- # FIXME: should we depend on Vendorificator::Config here?
27
- Vendorificator::Config.each_module do |mod|
28
- remote_head = remote_branches[mod.branch_name]
29
- ours = mod.head && mod.head.commit.sha
30
- theirs = remote_head && remote_head.commit.sha
31
-
32
- if remote_head
33
- if not mod.head
34
- say_status 'new', mod.branch_name, :yellow
35
- git.branch({:track=>true}, mod.branch_name, remote_head.name) unless options[:dry_run]
36
- elsif ours == theirs
37
- say_status 'unchanged', mod.branch_name
38
- elsif fast_forwardable?(theirs, ours)
39
- say_status 'updated', mod.name, :yellow
40
- unless options[:dry_run]
41
- mod.in_branch do
42
- git.merge({:ff_only => true}, remote_head.name)
43
- end
44
- end
45
- elsif fast_forwardable?(ours, theirs)
46
- say_status 'older', mod.branch_name
47
- else
48
- say_status 'complicated', mod.branch_name, :red
49
- indent do
50
- say 'Merge it yourself.'
51
- end
52
- end
53
- else
54
- say_status 'unknown', mod.branch_name
55
- end
56
- end
57
-
58
- private
59
-
60
- def conf
61
- Vendorificator::Config
62
- end
63
-
64
- def say_status(*args)
65
- conf[:shell].say_status(*args) if conf[:shell]
66
- end
67
- end
68
- end
69
- end