r10k 1.3.0 → 1.3.1

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NWI1YTM1NWFjOTc0OWYzZTY4MzY0Y2YzY2JiOGE2ZjJhMWNiYTkxMg==
4
+ ZGE0OGNlNWExOWY4OWQ4NjE2NjM1MjQ5MDYzYjc2MjMxN2JkYzQwYw==
5
5
  data.tar.gz: !binary |-
6
- NWEwY2EwNjg0ZjUyNDFiNjRkMTFkMWFiYTc5ZmIwZGM1ZDdlYTJkOQ==
6
+ MDg5MWRkNTVlODMyNzlmNzI1Zjk1NzhmOWYwMzc1YWY4NjA1YTJiOA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NmJhMWRmNWNlMmI5OTAzZDU5MWViZDc2N2FkOGRiZjY4NzRkM2YzZGI5ZmUw
10
- MWVhOWQ0MmUzYzNmOTU0YWI3MzdhOThjZjkxOTM3ZGQyZmM4MjRjYzM3YjE4
11
- MTBkODRlZTkwMzRiMTVkZDU2ZWVlZDllOGZmYTJkMjlhZDk0MTc=
9
+ YTkxMjk0Y2I1NDVhMDI4NGUwN2EwMjc2NTc2ZTg0YjYzMDlkNDE1ZGUxODk3
10
+ OGEwY2FlZGU4ZGI3YmU2YzE3N2U4YTc5NjAyZmIzMTU4NWJhZGY0M2QzNmVj
11
+ NTA4MGQyNWJiMWQ3MjhhZjE1MmZkMDExOGQ3NmRjM2Y4MjE0ZDY=
12
12
  data.tar.gz: !binary |-
13
- ZTVlZWU3NTY1ZjhjYmMyZjEzMTRkOGU1NDk3MmNjOGZkOWIyZDVjOWY2YzQw
14
- MDQyZjZkYTEwM2VmNTMwNWU5YWJmMjIxY2E1YThhYTRiOTAyNWE1ZjAzZDk0
15
- MjRhMTUyYzdiZmQ4NzgxN2NlZjAyMmZiMWQ0OTFjNTYwZjE0YjI=
13
+ ZDNmNmE2NTY1YTVkYjY2YWMzMGMzMDIwOTQ2MGQ4YjQ1NmExODdjNjE0NzI2
14
+ YjE4NGZlYTUwZWRiM2ZlZWJjMDIyZTAyOTgyYjhhZTYzZTgxMTA4Y2JjZTkz
15
+ YWI3ZDI3MzViMzY1Yjc1OWRjNjMwYjY3ZDhmZjE3OGY3NWU0YWI=
@@ -1,6 +1,27 @@
1
1
  CHANGELOG
2
2
  =========
3
3
 
4
+ 1.3.1
5
+ -----
6
+
7
+ 2014/07/16
8
+
9
+ ### User notes
10
+
11
+ (GH-161) Deployments fail where a branch has \W in the git branch name
12
+
13
+ In 1.3.0 environment naming was partially reworked to allow better handling of
14
+ per-environment deployment, but unfortunately this caused a regression where
15
+ environments would be differently named in 1.3.0. This fix changes the
16
+ environment deployment on a per-name basis to use the normalized name instead
17
+ of the raw Git branch name.
18
+
19
+ This bugfix release also incorporates all fixes added in 1.2.2.
20
+
21
+ ### Thanks
22
+
23
+ Thanks to Chris Spence for his work on this release.
24
+
4
25
  1.3.0
5
26
  -----
6
27
 
@@ -64,6 +85,41 @@ long run r10k will add a plugin system for loading additional code from
64
85
  Rubygems and other sources, so r10k will be extensible without requiring
65
86
  modifications to the source.
66
87
 
88
+ 1.2.2
89
+ -----
90
+
91
+ 2014/07/16
92
+
93
+ ### User Notes
94
+
95
+ (GH-165) `r10k puppetfile` only consumes handled command line options.
96
+
97
+ Previously, passing `-v` or other commands when running `r10k puppetfile *`
98
+ could result in this error:
99
+
100
+ r10k puppetfile install --help --trace
101
+ Error while running: #<RuntimeError: Unrecognized options: help>
102
+
103
+ This was due to overly greedy code passing in all options from the command line
104
+ to the TaskRunner. This has been fixed so only known options are passed along,
105
+ and options that aren't relevant (such as :verbose) will be ignored.
106
+
107
+ (GH-158) Log levels are now documented in the command line --help pages.
108
+
109
+ (GH-137) Git remotes are now correctly updated.
110
+
111
+ A regression in the Git remote handling meant that git remotes would never be
112
+ properly updated when switching Git environments and modules from one remote
113
+ to another, and the git alternates file was never updated properly. This has
114
+ been fixed so that when the Git remote is updated, all references to the
115
+ remotes and alternates will be updated.
116
+
117
+ (GH-163) All Git tags are deleted when switching Git remotes
118
+
119
+ Git tags cannot necessarily be transferred from one Git repository to another,
120
+ so when a Git repo has its remotes changed all tags are deleted to prevent stale
121
+ tags from overwriting tags from the new repo.
122
+
67
123
  1.2.1
68
124
  -----
69
125
 
@@ -15,10 +15,23 @@ module R10K::CLI
15
15
  complex environments.
16
16
  EOD
17
17
 
18
- flag :h, :help, 'Show help for this command'
18
+
19
+ flag :h, :help, 'Show help for this command' do |value, cmd|
20
+ # This is evil because we may not necessarily be called from the
21
+ # command line and have a meaningful ARGV to scan. However the best
22
+ # way of having a globally useful --help command is to define the
23
+ # behavior in the block of the option to immediately handle it and exit
24
+ # and we don't have access to the verbose option, so the simple method
25
+ # is to simply scan ARGV.
26
+ verbose = (ARGV.include?('-v') || ARGV.include?('--verbose'))
27
+ puts cmd.help(:verbose => verbose)
28
+ exit 0
29
+ end
30
+
19
31
  flag :t, :trace, 'Display stack traces on application crash'
20
32
 
21
- optional :v, :verbose, 'Set verbosity level' do |value, cmd|
33
+ loglevels = R10K::Logging::LOG_LEVELS.reverse.map(&:downcase).join(", ")
34
+ optional :v, :verbose, "Set log verbosity. Valid values: #{loglevels}" do |value, cmd|
22
35
  case value
23
36
  when true
24
37
  R10K::Logging.level = 'INFO'
@@ -51,10 +51,6 @@ scheduled. On subsequent deployments, Puppetfile deployment will default to off.
51
51
  DESCRIPTION
52
52
 
53
53
  flag :p, :puppetfile, 'Deploy modules from a puppetfile'
54
- flag :h, :help, 'Show help for this command' do |value, cmd|
55
- puts cmd.help
56
- exit 0
57
- end
58
54
 
59
55
  run do |opts, args, cmd|
60
56
  deploy = R10K::Deployment.load_config(opts[:config])
@@ -90,10 +86,6 @@ It will load the Puppetfile configurations out of all environments, and will
90
86
  try to deploy the given module names in all environments.
91
87
  DESCRIPTION
92
88
 
93
- flag :h, :help, 'Show help for this command' do |value, cmd|
94
- puts cmd.help
95
- exit 0
96
- end
97
89
  required :e, :environment, 'Update the modules in the given environment'
98
90
 
99
91
  run do |opts, args, cmd|
@@ -122,10 +114,6 @@ try to deploy the given module names in all environments.
122
114
  summary 'Display environments and modules in the deployment'
123
115
 
124
116
  flag :p, :puppetfile, 'Display Puppetfile modules'
125
- flag :h, :help, 'Show help for this command' do |value, cmd|
126
- puts cmd.help
127
- exit 0
128
- end
129
117
 
130
118
  run do |opts, args, cmd|
131
119
  deploy = R10K::Deployment.load_config(opts[:config])
@@ -37,7 +37,7 @@ Puppetfile (http://bombasticmonkey.com/librarian-puppet/).
37
37
 
38
38
  puppetfile = R10K::Puppetfile.new(puppetfile_root, puppetfile_path, puppetfile)
39
39
 
40
- runner = R10K::TaskRunner.new(opts)
40
+ runner = R10K::TaskRunner.new(:trace => opts[:trace])
41
41
  task = R10K::Task::Puppetfile::Sync.new(puppetfile)
42
42
  runner.append_task task
43
43
 
@@ -90,7 +90,7 @@ Puppetfile (http://bombasticmonkey.com/librarian-puppet/).
90
90
 
91
91
  puppetfile = R10K::Puppetfile.new(puppetfile_root, puppetfile_path, puppetfile)
92
92
 
93
- runner = R10K::TaskRunner.new(opts)
93
+ runner = R10K::TaskRunner.new(:trace => opts[:trace])
94
94
  task = R10K::Task::Puppetfile::Purge.new(puppetfile)
95
95
  runner.append_task task
96
96
 
@@ -10,6 +10,7 @@ module R10K
10
10
 
11
11
  require 'r10k/git/repository'
12
12
  require 'r10k/git/cache'
13
+ require 'r10k/git/alternates'
13
14
  require 'r10k/git/working_dir'
14
15
  end
15
16
  end
@@ -0,0 +1,49 @@
1
+ require 'pathname'
2
+
3
+ # Manage `$GIT_DIR/objects/info/alternates`
4
+ #
5
+ # @see man gitrepository-layout(5)
6
+ class R10K::Git::Alternates
7
+
8
+ # @attribute [r] file
9
+ # @return [Pathname] The alternates file
10
+ attr_reader :file
11
+
12
+ # @param git_dir [String] The path to the git repository
13
+ def initialize(git_dir)
14
+ @file = Pathname.new(File.join(git_dir, 'objects', 'info', 'alternates'))
15
+ end
16
+
17
+ def to_a
18
+ read()
19
+ end
20
+
21
+ def <<(path)
22
+ write(to_a << path)
23
+ end
24
+
25
+ def include?(path)
26
+ to_a.include?(path)
27
+ end
28
+
29
+ private
30
+
31
+ def write(entries)
32
+ if ! @file.parent.directory?
33
+ raise R10K::Git::GitError, "Cannot write #{@file.to_path}; parent directory does not exist"
34
+ end
35
+ @file.open("w") do |fh|
36
+ entries.each do |entry|
37
+ fh.puts(entry)
38
+ end
39
+ end
40
+ end
41
+
42
+ def read
43
+ entries = []
44
+ if @file.file?
45
+ entries = @file.readlines.map(&:chomp)
46
+ end
47
+ entries
48
+ end
49
+ end
@@ -84,7 +84,7 @@ class R10K::Git::Repository
84
84
 
85
85
  ret = {}
86
86
  output.stdout.each_line do |line|
87
- next if line.match /\(push\)/
87
+ next if line.match(/\(push\)/)
88
88
  name, url, _ = line.split(/\s+/)
89
89
  ret[name] = url
90
90
  end
@@ -92,6 +92,13 @@ class R10K::Git::Repository
92
92
  ret
93
93
  end
94
94
 
95
+ def tags
96
+ entries = []
97
+ output = git(['tag', '-l'], :git_dir => @git_dir).stdout
98
+ output.each_line { |line| entries << line.chomp }
99
+ entries
100
+ end
101
+
95
102
  private
96
103
 
97
104
  # Fetch objects and refs from the given git remote
@@ -40,7 +40,8 @@ class R10K::Git::WorkingDir < R10K::Git::Repository
40
40
  @full_path = File.join(@basedir, @dirname)
41
41
  @git_dir = File.join(@full_path, '.git')
42
42
 
43
- @cache = R10K::Git::Cache.generate(@remote)
43
+ @alternates = R10K::Git::Alternates.new(@git_dir)
44
+ @cache = R10K::Git::Cache.generate(@remote)
44
45
 
45
46
  if ref.is_a? String
46
47
  @ref = R10K::Git::Ref.new(ref, self)
@@ -60,7 +61,9 @@ class R10K::Git::WorkingDir < R10K::Git::Repository
60
61
  end
61
62
 
62
63
  def update
63
- if fetch?
64
+ update_remotes if update_remotes?
65
+
66
+ if ref_needs_fetch?
64
67
  fetch_from_cache
65
68
  checkout(@ref)
66
69
  elsif needs_checkout?
@@ -113,22 +116,17 @@ class R10K::Git::WorkingDir < R10K::Git::Repository
113
116
 
114
117
  private
115
118
 
116
- def fetch?
119
+ # Do we need to fetch additional objects and refs in order to resolve the given ref?
120
+ # @return [true, false]
121
+ def ref_needs_fetch?
117
122
  @ref.fetch?
118
123
  end
119
124
 
120
125
  def fetch_from_cache
121
- set_cache_remote
122
126
  @cache.sync
123
127
  fetch('cache')
124
128
  end
125
129
 
126
- def set_cache_remote
127
- if self.remote != @cache.remote
128
- git ["remote", "set-url", "cache", @cache.git_dir], :path => @full_path
129
- end
130
- end
131
-
132
130
  # Perform a non-bare clone of a git repository.
133
131
  def clone
134
132
  @cache.sync
@@ -150,6 +148,30 @@ class R10K::Git::WorkingDir < R10K::Git::Repository
150
148
  expected = ref.sha1
151
149
  actual = rev_parse('HEAD')
152
150
 
153
- ! (expected == actual)
151
+ !(expected == actual)
152
+ end
153
+
154
+ def update_remotes?
155
+ real_remotes = remotes
156
+
157
+ expected_origin = @remote
158
+ expected_cache = @cache.git_dir
159
+
160
+ !(expected_origin == real_remotes['origin'] and expected_cache == real_remotes['cache'])
161
+ end
162
+
163
+ def update_remotes
164
+ # todo: remove all existing refs as they may belong to the old remote
165
+ git ['remote', 'set-url', 'origin', remote], :path => @full_path
166
+ git ['remote', 'set-url', 'cache', @cache.git_dir], :path => @full_path
167
+ @alternates << File.join(@cache.git_dir, 'objects')
168
+ logger.debug("Removing stale git tags from #{@full_path}")
169
+ remove_tags
170
+ end
171
+
172
+ def remove_tags
173
+ tags.each do |tag|
174
+ git ['tag', '-d', tag], :path => @full_path
175
+ end
154
176
  end
155
177
  end
@@ -23,8 +23,14 @@ module Deployment
23
23
  # while this should be optimized that optimization can wait a while.
24
24
  names.each do |env_name|
25
25
 
26
+ # Elsewhere, we sanitise the env.dirname to sub any \W to _
27
+ # For this to match here (a single environment deploy where the
28
+ # branch name has \W we need to sanitise the branch name to match
29
+
30
+ safe_branch_name = env_name.gsub(/\W/,'_')
31
+
26
32
  matching = all_environments.select do |env|
27
- env.dirname == env_name
33
+ env.dirname == safe_branch_name
28
34
  end
29
35
 
30
36
  if matching.empty?
@@ -1,3 +1,3 @@
1
1
  module R10K
2
- VERSION = '1.3.0'
2
+ VERSION = '1.3.1'
3
3
  end
@@ -0,0 +1,90 @@
1
+ require 'spec_helper'
2
+ require 'stringio'
3
+ require 'r10k/git'
4
+
5
+ describe R10K::Git::Alternates do
6
+ subject { described_class.new("/some/nonexistent/path/.git") }
7
+
8
+ it "interacts with the alternates file in the given git repository" do
9
+ expect(subject.file.to_path).to eq("/some/nonexistent/path/.git/objects/info/alternates")
10
+ end
11
+
12
+ describe "reading alternate object entries" do
13
+ it "reads the alternates file and splits on lines" do
14
+ expect(subject.file).to receive(:file?).and_return true
15
+ expect(subject.file).to receive(:readlines).and_return([
16
+ "/var/cache/r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git\n",
17
+ "/vagrant/.r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git\n",
18
+ ])
19
+
20
+ expect(subject.to_a).to eq([
21
+ "/var/cache/r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git",
22
+ "/vagrant/.r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git",
23
+ ])
24
+ end
25
+
26
+ it "returns an empty array when the file is not present" do
27
+ expect(subject.file).to receive(:file?).and_return false
28
+ expect(subject.file).to receive(:readlines).never
29
+ expect(subject.to_a).to eq([])
30
+ end
31
+ end
32
+
33
+ describe "determining if an entry is already present" do
34
+ before do
35
+ allow(subject).to receive(:to_a).and_return([
36
+ "/var/cache/r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git",
37
+ "/vagrant/.r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git",
38
+ ])
39
+ end
40
+
41
+ it "is true if the element is in the array of read entries" do
42
+ expect(subject).to include("/vagrant/.r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git")
43
+ end
44
+
45
+ it "is false if the element is not in the array of read entries" do
46
+ expect(subject).to_not include("/tmp/.r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git")
47
+ end
48
+ end
49
+
50
+ describe "appending a new alternate object entry" do
51
+ describe "and the git objects/info directory does not exist" do
52
+ it "raises an error when the parent directory does not exist" do
53
+ expect {
54
+ subject << "/tmp/.r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git"
55
+ }.to raise_error(R10K::Git::GitError,"Cannot write /some/nonexistent/path/.git/objects/info/alternates; parent directory does not exist")
56
+ end
57
+ end
58
+
59
+ describe "and the git objects/info directory exists" do
60
+ let(:io) { StringIO.new }
61
+
62
+ before do
63
+ expect(subject.file).to receive(:open).with('w').and_yield(io)
64
+ subject.file.stub_chain(:parent, :directory?).and_return true
65
+ end
66
+
67
+
68
+ it "creates the alternates file with the new entry when not present" do
69
+ expect(subject).to receive(:to_a).and_return([])
70
+ subject << "/tmp/.r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git"
71
+
72
+ expect(io.string).to eq("/tmp/.r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git\n")
73
+ end
74
+
75
+ it "rewrites the file with all alternate entries" do
76
+ expect(subject).to receive(:to_a).and_return([
77
+ "/var/cache/r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git",
78
+ "/vagrant/.r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git",
79
+ ])
80
+ subject << "/tmp/.r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git"
81
+
82
+ expect(io.string).to eq(<<-EOD)
83
+ /var/cache/r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git
84
+ /vagrant/.r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git
85
+ /tmp/.r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git
86
+ EOD
87
+ end
88
+ end
89
+ end
90
+ end
@@ -21,4 +21,14 @@ describe R10K::Git::Repository do
21
21
  })
22
22
  end
23
23
  end
24
+
25
+ describe "tags" do
26
+ let(:tags) { %w[0.1.1 0.1.2 0.1.3 0.1.4 0.2.0 0.3.0 2.0.0] }
27
+ let(:output) { tags.map {|x| x + "\n"}.join }
28
+
29
+ it "returns a list of tags for this repo" do
30
+ expect(subject).to receive(:git).with(%w[tag -l], anything).and_return(double(:stdout => output))
31
+ expect(subject.tags).to eq(tags)
32
+ end
33
+ end
24
34
  end
@@ -2,11 +2,120 @@ require 'spec_helper'
2
2
  require 'r10k/git'
3
3
 
4
4
  describe R10K::Git::WorkingDir do
5
+ include_context "fail on execution"
5
6
 
6
7
  describe "initializing" do
7
8
  it "generates a new cache for the remote" do
8
- wd = described_class.new('master', 'git://github.com/adrienthebo/r10k-fixture-repo', '/tmp')
9
+ wd = described_class.new('master', 'git://github.com/adrienthebo/r10k-fixture-repo', '/some/nonexistent/dir')
9
10
  wd.cache.should be_kind_of R10K::Git::Cache
10
11
  end
12
+
13
+ it "uses the provided ref as the dirname when no dirname is given" do
14
+ wd = described_class.new('master', 'git://github.com/adrienthebo/r10k-fixture-repo', '/some/nonexistent/dir')
15
+ expect(wd.dirname).to eq('master')
16
+ end
17
+
18
+ it "uses an explicit dirname when given" do
19
+ wd = described_class.new('master', 'git://github.com/adrienthebo/r10k-fixture-repo', '/some/nonexistent/dir', 'mydir')
20
+ expect(wd.dirname).to eq('mydir')
21
+ end
22
+ end
23
+
24
+ describe "synchronizing the working directory" do
25
+ subject { described_class.new('master', 'git://github.com/adrienthebo/r10k-fixture-repo', '/some/nonexistent/dir') }
26
+ it "clones the repository when the repository doesn't exist" do
27
+ expect(subject).to receive(:cloned?).and_return false
28
+ expect(subject).to receive(:clone)
29
+ subject.sync
30
+ end
31
+
32
+ it "updates the repository when the repository already exists" do
33
+ expect(subject).to receive(:cloned?).and_return true
34
+ expect(subject).to receive(:update)
35
+ subject.sync
36
+ end
37
+ end
38
+
39
+ describe "when cloning a new repository" do
40
+ subject { described_class.new('master', 'git://github.com/adrienthebo/r10k-fixture-repo', '/some/nonexistent/dir') }
41
+
42
+ before do
43
+ allow(subject).to receive(:cloned?).and_return false
44
+ end
45
+
46
+ it "updates the cache before cloning" do
47
+ expect(subject.cache).to receive(:sync)
48
+ allow(subject).to receive(:git)
49
+ allow(subject).to receive(:checkout)
50
+ subject.sync
51
+ end
52
+
53
+ it "clones the repository and uses the cache git dir as an object reference" do
54
+ allow(subject.cache).to receive(:sync)
55
+ expect(subject).to receive(:git).with(['clone', '--reference', subject.cache.git_dir,
56
+ 'git://github.com/adrienthebo/r10k-fixture-repo',
57
+ '/some/nonexistent/dir/master'])
58
+ expect(subject).to receive(:git).with(['remote', 'add', 'cache', subject.cache.git_dir],
59
+ an_instance_of(Hash))
60
+
61
+ expect(subject).to receive(:git).with(['fetch', 'cache'], an_instance_of(Hash))
62
+ allow(subject).to receive(:checkout)
63
+ subject.sync
64
+ end
65
+
66
+ it 'checks out the specific ref after the clone' do
67
+ allow(subject.cache).to receive(:sync)
68
+ allow(subject).to receive(:git)
69
+ expect(subject).to receive(:checkout)
70
+ subject.sync
71
+ end
72
+ end
73
+
74
+ describe "updating an existing repository" do
75
+ subject { described_class.new('master', 'git://github.com/adrienthebo/r10k-fixture-repo', '/some/nonexistent/dir') }
76
+
77
+ before do
78
+ allow(subject).to receive(:cloned?).and_return true
79
+ end
80
+
81
+ it "updates the remotes when they are out of sync" do
82
+ allow(subject).to receive(:ref_needs_fetch?).and_return false
83
+ allow(subject).to receive(:needs_checkout?).and_return false
84
+
85
+ expect(subject).to receive(:update_remotes?).and_return true
86
+ expect(subject).to receive(:update_remotes)
87
+
88
+ subject.sync
89
+ end
90
+
91
+ it "updates the cache when the ref requires an update" do
92
+ allow(subject).to receive(:update_remotes?).and_return false
93
+
94
+ expect(subject).to receive(:ref_needs_fetch?).and_return true
95
+ expect(subject).to receive(:fetch_from_cache)
96
+ expect(subject).to receive(:checkout).with(an_instance_of(R10K::Git::Ref))
97
+
98
+ subject.sync
99
+ end
100
+
101
+ it "checks out the ref when the wrong commit is checked out" do
102
+ allow(subject).to receive(:update_remotes?).and_return false
103
+ allow(subject).to receive(:ref_needs_fetch?).and_return false
104
+
105
+ expect(subject).to receive(:needs_checkout?).and_return true
106
+ expect(subject).to receive(:checkout).with(an_instance_of(R10K::Git::Ref))
107
+
108
+ subject.sync
109
+ end
110
+
111
+ it "doesn't update the repo when everything is in sync" do
112
+ allow(subject).to receive(:update_remotes?).and_return false
113
+ allow(subject).to receive(:ref_needs_fetch?).and_return false
114
+ allow(subject).to receive(:needs_checkout?).and_return false
115
+
116
+ expect(subject).to_not receive(:checkout)
117
+
118
+ subject.sync
119
+ end
11
120
  end
12
121
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: r10k
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrien Thebo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-30 00:00:00.000000000 Z
11
+ date: 2014-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colored
@@ -231,6 +231,7 @@ files:
231
231
  - lib/r10k/errors.rb
232
232
  - lib/r10k/execution.rb
233
233
  - lib/r10k/git.rb
234
+ - lib/r10k/git/alternates.rb
234
235
  - lib/r10k/git/cache.rb
235
236
  - lib/r10k/git/commit.rb
236
237
  - lib/r10k/git/errors.rb
@@ -311,6 +312,7 @@ files:
311
312
  - spec/unit/deployment/source_spec.rb
312
313
  - spec/unit/environment/git_spec.rb
313
314
  - spec/unit/environment/svn_spec.rb
315
+ - spec/unit/git/alternates_spec.rb
314
316
  - spec/unit/git/cache_spec.rb
315
317
  - spec/unit/git/commit_spec.rb
316
318
  - spec/unit/git/head_spec.rb
@@ -407,6 +409,7 @@ test_files:
407
409
  - spec/unit/git/commit_spec.rb
408
410
  - spec/unit/git/repository_spec.rb
409
411
  - spec/unit/git/head_spec.rb
412
+ - spec/unit/git/alternates_spec.rb
410
413
  - spec/unit/git/tag_spec.rb
411
414
  - spec/unit/keyed_factory_spec.rb
412
415
  - spec/unit/deployment/environment_spec.rb