r10k 1.5.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.travis.yml +0 -1
- data/CHANGELOG.mkd +63 -0
- data/Gemfile +2 -2
- data/README.mkd +1 -10
- data/doc/dynamic-environments/configuration.mkd +24 -6
- data/doc/dynamic-environments/quickstart.mkd +1 -1
- data/integration/Gemfile +1 -1
- data/integration/configs/pe/centos-5-64mda +25 -0
- data/integration/configs/pe/centos-6-64mda +1 -1
- data/integration/configs/pe/centos-7-64mda +1 -1
- data/integration/configs/pe/debian-6-64mda +1 -1
- data/integration/configs/pe/debian-7-64mda +1 -1
- data/integration/configs/pe/redhat-6-64mda +1 -1
- data/integration/configs/pe/redhat-7-64mda +1 -1
- data/integration/configs/pe/sles-11-64mda +1 -1
- data/integration/configs/pe/sles-12-64mda +25 -0
- data/integration/configs/pe/ubuntu-1004-64mda +1 -1
- data/integration/configs/pe/ubuntu-1204-64mda +1 -1
- data/integration/configs/pe/ubuntu-1404-64mda +1 -1
- data/integration/files/pre-suite/git_config.pp.erb +19 -0
- data/integration/pre-suite/01_git_config.rb +5 -17
- data/integration/pre-suite/02_pe_r10k.rb +0 -2
- data/integration/scripts/README.mkd +86 -0
- data/integration/scripts/setup_r10k_env_centos5.sh +23 -0
- data/integration/scripts/setup_r10k_env_centos6.sh +23 -0
- data/integration/scripts/setup_r10k_env_rhel7.sh +23 -0
- data/integration/scripts/setup_r10k_env_sles11.sh +23 -0
- data/integration/scripts/setup_r10k_env_sles12.sh +23 -0
- data/integration/scripts/setup_r10k_env_ubuntu1004.sh +23 -0
- data/integration/scripts/setup_r10k_env_ubuntu1204.sh +23 -0
- data/integration/scripts/setup_r10k_env_ubuntu1404.sh +23 -0
- data/integration/tests/basic_functionality/negative/neg_invalid_git_provider.rb +44 -0
- data/integration/tests/basic_functionality/rugged_git_provider_with_ssh.rb +106 -0
- data/integration/tests/basic_functionality/rugged_git_provider_without_ssh.rb +107 -0
- data/integration/tests/git_source/git_source_git.rb +1 -1
- data/integration/tests/git_source/git_source_ssh.rb +1 -1
- data/integration/tests/git_source/negative/neg_git_unauthorized_https.rb +1 -1
- data/integration/tests/git_source/negative/neg_git_unauthorized_ssh.rb +1 -1
- data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_basedir.rb +1 -1
- data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_module.rb +8 -2
- data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_module_ref.rb +1 -1
- data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_remote.rb +1 -1
- data/integration/tests/user_scenario/basic_workflow/negative/neg_branch_name_collision.rb +1 -1
- data/integration/tests/user_scenario/basic_workflow/negative/neg_disk_full.rb +5 -1
- data/integration/tests/user_scenario/basic_workflow/negative/neg_duplicate_module_names.rb +3 -3
- data/integration/tests/user_scenario/basic_workflow/negative/neg_invalid_puppet_file.rb +1 -1
- data/integration/tests/user_scenario/basic_workflow/negative/neg_read_only.rb +1 -1
- data/integration/tests/user_scenario/basic_workflow/single_env_10000_files.rb +4 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_large_files.rb +4 -0
- data/integration/tests/user_scenario/complex_workflow/multi_env_unamanaged.rb +77 -0
- data/integration/tests/user_scenario/complex_workflow/single_env_git_module_update.rb +99 -0
- data/lib/r10k/action/deploy/display.rb +0 -1
- data/lib/r10k/action/runner.rb +20 -0
- data/lib/r10k/cli.rb +0 -3
- data/lib/r10k/cli/deploy.rb +0 -3
- data/lib/r10k/deployment.rb +1 -7
- data/lib/r10k/deployment/config.rb +15 -1
- data/lib/r10k/deployment/config/loader.rb +0 -11
- data/lib/r10k/environment/git.rb +0 -9
- data/lib/r10k/environment/svn.rb +0 -9
- data/lib/r10k/errors.rb +0 -3
- data/lib/r10k/feature.rb +24 -3
- data/lib/r10k/forge/module_release.rb +142 -0
- data/lib/r10k/git.rb +32 -11
- data/lib/r10k/module/forge.rb +25 -54
- data/lib/r10k/module_repository/forge.rb +2 -5
- data/lib/r10k/puppetfile.rb +1 -1
- data/lib/r10k/util/license.rb +20 -0
- data/lib/r10k/version.rb +1 -1
- data/lib/shared/puppet_forge/connection.rb +62 -0
- data/lib/shared/puppet_forge/error.rb +28 -0
- data/lib/shared/puppet_forge/tar.rb +10 -0
- data/lib/shared/puppet_forge/tar/mini.rb +81 -0
- data/lib/shared/puppet_forge/unpacker.rb +68 -0
- data/lib/shared/puppet_forge/v3.rb +13 -0
- data/lib/shared/puppet_forge/v3/module.rb +66 -0
- data/lib/shared/puppet_forge/v3/module_release.rb +73 -0
- data/lib/shared/puppet_forge/version.rb +3 -0
- data/r10k.gemspec +2 -2
- data/r10k.yaml.example +80 -5
- data/spec/spec_helper.rb +0 -12
- data/spec/unit/action/runner_spec.rb +53 -0
- data/spec/unit/deployment/config/loader_spec.rb +5 -19
- data/spec/unit/deployment/config_spec.rb +8 -0
- data/spec/unit/deployment_spec.rb +1 -1
- data/spec/unit/forge/module_release_spec.rb +130 -0
- data/spec/unit/git_spec.rb +5 -5
- data/spec/unit/module/forge_spec.rb +66 -116
- data/spec/unit/module_repository/forge_spec.rb +35 -5
- data/spec/unit/module_spec.rb +10 -10
- data/spec/unit/puppet_forge/connection_spec.rb +41 -0
- data/spec/unit/puppet_forge/tar/mini_spec.rb +87 -0
- data/spec/unit/puppet_forge/tar_spec.rb +9 -0
- data/spec/unit/puppet_forge/unpacker_spec.rb +59 -0
- data/spec/unit/puppet_forge/v3/module_release_spec.rb +68 -0
- data/spec/unit/puppet_forge/v3/module_spec.rb +67 -0
- metadata +48 -112
- data/lib/r10k/cli/environment.rb +0 -28
- data/lib/r10k/cli/environment/deploy.rb +0 -26
- data/lib/r10k/cli/environment/list.rb +0 -23
- data/lib/r10k/cli/environment/stale.rb +0 -24
- data/lib/r10k/cli/module.rb +0 -29
- data/lib/r10k/cli/module/deploy.rb +0 -27
- data/lib/r10k/cli/module/list.rb +0 -24
- data/lib/r10k/cli/synchronize.rb +0 -27
- data/lib/r10k/deployment/basedir.rb +0 -4
- data/lib/r10k/deployment/environment.rb +0 -20
- data/lib/r10k/deployment/source.rb +0 -37
- data/lib/r10k/git/commit.rb +0 -22
- data/lib/r10k/git/head.rb +0 -36
- data/lib/r10k/git/ref.rb +0 -66
- data/lib/r10k/git/remote_head.rb +0 -19
- data/lib/r10k/git/repository.rb +0 -158
- data/lib/r10k/git/tag.rb +0 -29
- data/lib/r10k/git/working_dir.rb +0 -186
- data/lib/r10k/registry.rb +0 -4
- data/lib/r10k/semver.rb +0 -128
- data/lib/r10k/task.rb +0 -12
- data/lib/r10k/task/deployment.rb +0 -164
- data/lib/r10k/task/environment.rb +0 -31
- data/lib/r10k/task/module.rb +0 -19
- data/lib/r10k/task/puppetfile.rb +0 -102
- data/lib/r10k/task_runner.rb +0 -72
- data/lib/r10k/util/monkey_patches.rb +0 -11
- data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/and_the_expected_version_is_latest/can_fetch_all_versions_of_a_given_module.yml +0 -187
- data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/and_the_expected_version_is_latest/can_fetch_the_latest_version_of_a_given_module.yml +0 -187
- data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/and_the_expected_version_is_latest/ignores_deleted_releases.yml +0 -190
- data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/it_handles_errors_from_forgeapi_puppetlabs_com/raises_an_error_for_a_non-existant_module.yml +0 -34
- data/spec/fixtures/vcr/cassettes/R10K_Module_Forge/and_the_expected_version_is_latest/sets_the_expected_version_based_on_the_latest_forge_version.yml +0 -103
- data/spec/shared-examples/git-ref.rb +0 -49
- data/spec/unit/deployment/environment_spec.rb +0 -25
- data/spec/unit/git/commit_spec.rb +0 -34
- data/spec/unit/git/head_spec.rb +0 -22
- data/spec/unit/git/ref_spec.rb +0 -45
- data/spec/unit/git/repository_spec.rb +0 -34
- data/spec/unit/git/tag_spec.rb +0 -32
- data/spec/unit/git/working_dir_spec.rb +0 -122
- data/spec/unit/util/monkey_patches_spec.rb +0 -20
data/lib/r10k/cli/environment.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'r10k/cli'
|
2
|
-
require 'cri'
|
3
|
-
|
4
|
-
module R10K::CLI
|
5
|
-
module Environment
|
6
|
-
def self.command
|
7
|
-
@cmd ||= Cri::Command.define do
|
8
|
-
name 'environment'
|
9
|
-
usage 'environment <subcommand>'
|
10
|
-
summary 'DEPRECATED: Operate on a specific environment'
|
11
|
-
|
12
|
-
required :c, :config, 'Specify a configuration file'
|
13
|
-
|
14
|
-
be_hidden
|
15
|
-
|
16
|
-
run do |opts, args, cmd|
|
17
|
-
puts cmd.help(:verbose => opts[:verbose])
|
18
|
-
exit 0
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
self.command.add_command(Environment.command)
|
24
|
-
end
|
25
|
-
|
26
|
-
require 'r10k/cli/environment/list'
|
27
|
-
require 'r10k/cli/environment/deploy'
|
28
|
-
require 'r10k/cli/environment/stale'
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'r10k/cli/environment'
|
2
|
-
require 'r10k/cli/deploy'
|
3
|
-
require 'cri'
|
4
|
-
|
5
|
-
module R10K::CLI::Environment
|
6
|
-
module Deploy
|
7
|
-
def self.command
|
8
|
-
@cmd ||= Cri::Command.define do
|
9
|
-
name 'deploy'
|
10
|
-
usage 'deploy <environment> <...>'
|
11
|
-
summary 'DEPRECATED: Deploy an environment'
|
12
|
-
|
13
|
-
flag :r, :recurse, 'Recursively update submodules'
|
14
|
-
flag :u, :update, "Enable or disable cache updating"
|
15
|
-
|
16
|
-
be_hidden
|
17
|
-
|
18
|
-
run do |opts, args, cmd|
|
19
|
-
logger.warn "This command is deprecated; please use `r10k deploy environment`"
|
20
|
-
R10K::CLI::Deploy::Environment.command.block.call(opts,args,cmd)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
self.command.add_command(Deploy.command)
|
26
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'r10k/cli/environment'
|
2
|
-
require 'r10k/cli/deploy'
|
3
|
-
require 'cri'
|
4
|
-
|
5
|
-
module R10K::CLI::Environment
|
6
|
-
module List
|
7
|
-
def self.command
|
8
|
-
@cmd ||= Cri::Command.define do
|
9
|
-
name 'list'
|
10
|
-
usage 'list'
|
11
|
-
summary 'DEPRECATED: List all available environments'
|
12
|
-
|
13
|
-
be_hidden
|
14
|
-
|
15
|
-
run do |opts, args, cmd|
|
16
|
-
logger.warn "This command is deprecated; please use `r10k deploy display`"
|
17
|
-
R10K::CLI::Deploy::Display.command.block.call(opts,args,cmd)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
self.command.add_command(List.command)
|
23
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'r10k/cli/environment'
|
2
|
-
require 'r10k/deployment'
|
3
|
-
require 'cri'
|
4
|
-
|
5
|
-
module R10K::CLI::Environment
|
6
|
-
module Stale
|
7
|
-
def self.command
|
8
|
-
@cmd ||= Cri::Command.define do
|
9
|
-
name 'stale'
|
10
|
-
usage 'stale <directory> [directory ...]'
|
11
|
-
summary 'REMOVED: List all stale environments'
|
12
|
-
|
13
|
-
description "This command has been removed in 1.0.0"
|
14
|
-
be_hidden
|
15
|
-
|
16
|
-
run do |opts, args, cmd|
|
17
|
-
$stderr.puts "#{cmd.name} has been removed in 1.0.0"
|
18
|
-
exit 1
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
self.command.add_command(Stale.command)
|
24
|
-
end
|
data/lib/r10k/cli/module.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'r10k/cli'
|
2
|
-
require 'cri'
|
3
|
-
|
4
|
-
module R10K::CLI
|
5
|
-
module Module
|
6
|
-
def self.command
|
7
|
-
@cmd ||= Cri::Command.define do
|
8
|
-
name 'module'
|
9
|
-
usage 'module <subcommand>'
|
10
|
-
summary 'DEPRECATED: Operate on a specific puppet module'
|
11
|
-
|
12
|
-
be_hidden
|
13
|
-
|
14
|
-
required :c, :config, 'Specify a configuration file'
|
15
|
-
|
16
|
-
required :e, :environment, 'Specify a particular environment'
|
17
|
-
|
18
|
-
run do |opts, args, cmd|
|
19
|
-
puts cmd.help(:verbose => opts[:verbose])
|
20
|
-
exit 0
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
self.command.add_command(Module.command)
|
26
|
-
end
|
27
|
-
|
28
|
-
require 'r10k/cli/module/deploy'
|
29
|
-
require 'r10k/cli/module/list'
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'r10k/cli/module'
|
2
|
-
require 'r10k/deployment'
|
3
|
-
require 'cri'
|
4
|
-
|
5
|
-
require 'fileutils'
|
6
|
-
|
7
|
-
module R10K::CLI::Module
|
8
|
-
module Deploy
|
9
|
-
def self.command
|
10
|
-
@cmd ||= Cri::Command.define do
|
11
|
-
name 'deploy'
|
12
|
-
usage 'deploy [module name] <module name> ...'
|
13
|
-
summary 'DEPRECATED: Deploy a module'
|
14
|
-
|
15
|
-
be_hidden
|
16
|
-
|
17
|
-
flag :u, :update, "Update module cache"
|
18
|
-
|
19
|
-
run do |opts, args, cmd|
|
20
|
-
logger.warn "This command is deprecated; please use `r10k deploy module`"
|
21
|
-
R10K::CLI::Deploy::Module.command.block.call(opts,args,cmd)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
self.command.add_command(Deploy.command)
|
27
|
-
end
|
data/lib/r10k/cli/module/list.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'r10k/cli/module'
|
2
|
-
require 'r10k/cli/deploy'
|
3
|
-
require 'cri'
|
4
|
-
|
5
|
-
module R10K::CLI::Module
|
6
|
-
module List
|
7
|
-
def self.command
|
8
|
-
@cmd ||= Cri::Command.define do
|
9
|
-
name 'list'
|
10
|
-
usage 'list'
|
11
|
-
summary 'DEPRECATED: List modules that are instantiated in environments'
|
12
|
-
|
13
|
-
be_hidden
|
14
|
-
|
15
|
-
run do |opts, args, cmd|
|
16
|
-
logger.warn "This command is deprecated; please use `r10k deploy display`"
|
17
|
-
R10K::CLI::Deploy::Display.command.block.call(opts,args,cmd)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
self.command.add_command(List.command)
|
23
|
-
end
|
24
|
-
|
data/lib/r10k/cli/synchronize.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'r10k/cli/deploy'
|
2
|
-
|
3
|
-
require 'cri'
|
4
|
-
|
5
|
-
module R10K::CLI
|
6
|
-
module Synchronize
|
7
|
-
def self.command
|
8
|
-
@cmd ||= Cri::Command.define do
|
9
|
-
name 'synchronize'
|
10
|
-
usage 'synchronize <options>'
|
11
|
-
summary 'DEPRECATED: Fully synchronize all environments'
|
12
|
-
|
13
|
-
required :c, :config, 'Specify a configuration file'
|
14
|
-
|
15
|
-
be_hidden
|
16
|
-
|
17
|
-
run do |opts, args, cmd|
|
18
|
-
logger.warn "#{cmd.name} is deprecated; please use `r10k deploy environment --puppetfile`"
|
19
|
-
|
20
|
-
opts.merge!({:puppetfile => true})
|
21
|
-
R10K::CLI::Deploy::Environment.command.block.call(opts,args,cmd)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
self.command.add_command(Synchronize.command)
|
27
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'r10k/deployment'
|
2
|
-
require 'r10k/environment'
|
3
|
-
|
4
|
-
class R10K::Deployment::Environment
|
5
|
-
|
6
|
-
# @param [String] ref
|
7
|
-
# @param [String] remote
|
8
|
-
# @param [String] basedir
|
9
|
-
# @param [String] dirname The directory to clone the root into, defaults to ref
|
10
|
-
# @param [String] source_name An additional string which may be used with ref to build dirname
|
11
|
-
#
|
12
|
-
# @deprecated
|
13
|
-
# @return [R10K::Environment::Git]
|
14
|
-
def self.new(ref, remote, basedir, dirname = nil, source_name = "")
|
15
|
-
alternate_name = source_name.empty? ? ref : source_name + "_" + ref
|
16
|
-
dirname = dirname || alternate_name
|
17
|
-
|
18
|
-
R10K::Environment::Git.new(ref, basedir, dirname, {:remote => remote, :ref => ref})
|
19
|
-
end
|
20
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'r10k/source'
|
2
|
-
require 'r10k/util/symbolize_keys'
|
3
|
-
|
4
|
-
module R10K
|
5
|
-
class Deployment
|
6
|
-
# :nocov:
|
7
|
-
class Source
|
8
|
-
# Create a new source from a hash representation
|
9
|
-
#
|
10
|
-
# @param name [String] The name of the source
|
11
|
-
# @param opts [Hash] The properties to use for the source
|
12
|
-
#
|
13
|
-
# @option opts [String] :remote The git remote for the given source
|
14
|
-
# @option opts [String] :basedir The directory to create environments in
|
15
|
-
# @option opts [true, false] :prefix Whether the environment names should
|
16
|
-
# be prefixed by the source name. Defaults to false.
|
17
|
-
#
|
18
|
-
# @deprecated
|
19
|
-
# @return [R10K::Source::Base]
|
20
|
-
def self.vivify(name, attrs)
|
21
|
-
R10K::Util::SymbolizeKeys.symbolize_keys!(attrs)
|
22
|
-
|
23
|
-
remote = attrs.delete(:remote)
|
24
|
-
basedir = attrs.delete(:basedir)
|
25
|
-
prefix = attrs.delete(:prefix)
|
26
|
-
|
27
|
-
raise ArgumentError, "Unrecognized attributes for #{self.name}: #{attrs.inspect}" unless attrs.empty?
|
28
|
-
new(name, remote, basedir, prefix)
|
29
|
-
end
|
30
|
-
|
31
|
-
def self.new(name, remote, basedir, prefix)
|
32
|
-
R10K::Source::Git.new(name, basedir, {:prefix => prefix, :remote => remote})
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
# :nocov:
|
37
|
-
end
|
data/lib/r10k/git/commit.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'r10k/git/ref'
|
2
|
-
require 'r10k/git/repository'
|
3
|
-
|
4
|
-
# commit: A 40-byte hex representation of a SHA1 referencing a specific commit
|
5
|
-
# @see https://www.kernel.org/pub/software/scm/git/docs/gitglossary.html
|
6
|
-
# @api private
|
7
|
-
class R10K::Git::Commit < R10K::Git::Ref
|
8
|
-
|
9
|
-
# @!attribute [r] commit
|
10
|
-
# @return [String] The git commit
|
11
|
-
attr_reader :commit
|
12
|
-
alias :ref :commit
|
13
|
-
|
14
|
-
def initialize(commit, repository = nil)
|
15
|
-
@commit = commit
|
16
|
-
@repository = repository
|
17
|
-
end
|
18
|
-
|
19
|
-
def fetch?
|
20
|
-
! resolvable?
|
21
|
-
end
|
22
|
-
end
|
data/lib/r10k/git/head.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'r10k/git'
|
2
|
-
require 'r10k/git/ref'
|
3
|
-
require 'r10k/git/repository'
|
4
|
-
|
5
|
-
|
6
|
-
# head: A named reference to the commit at the tip of a branch. Heads are
|
7
|
-
# stored in a file in $GIT_DIR/refs/heads/ directory. except when using packed
|
8
|
-
#
|
9
|
-
# @deprecated This has been replaced by the ShellGit provider and the
|
10
|
-
# StatefulRepository class and will be removed in 2.0.0
|
11
|
-
#
|
12
|
-
# @see https://www.kernel.org/pub/software/scm/git/docs/gitglossary.html
|
13
|
-
# @api private
|
14
|
-
class R10K::Git::Head < R10K::Git::Ref
|
15
|
-
|
16
|
-
# @!attribute [r] head
|
17
|
-
# @return [String] The git head
|
18
|
-
attr_reader :head
|
19
|
-
alias :ref :head
|
20
|
-
|
21
|
-
def initialize(head, repository = nil)
|
22
|
-
@head = head
|
23
|
-
@repository = repository
|
24
|
-
end
|
25
|
-
|
26
|
-
# def sha1
|
27
|
-
# TODO ensure that @head is an actual head as opposed to a tag or other
|
28
|
-
# hooliganism.
|
29
|
-
#end
|
30
|
-
|
31
|
-
# If we are tracking a branch, we should always try to fetch a newer version
|
32
|
-
# of that branch.
|
33
|
-
def fetch?
|
34
|
-
true
|
35
|
-
end
|
36
|
-
end
|
data/lib/r10k/git/ref.rb
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
require 'r10k/git'
|
2
|
-
require 'r10k/git/repository'
|
3
|
-
|
4
|
-
# ref: A 40-byte hex representation of a SHA1 or a name that denotes a
|
5
|
-
# particular object. They may be stored in a file under $GIT_DIR/refs/
|
6
|
-
# directory, or in the $GIT_DIR/packed-refs file.
|
7
|
-
#
|
8
|
-
# @deprecated This has been replaced by the ShellGit provider and the
|
9
|
-
# StatefulRepository class and will be removed in 2.0.0
|
10
|
-
#
|
11
|
-
# @see https://www.kernel.org/pub/software/scm/git/docs/gitglossary.html
|
12
|
-
# @api private
|
13
|
-
class R10K::Git::Ref
|
14
|
-
|
15
|
-
# @!attribute [r] ref
|
16
|
-
# @return [String] The git reference
|
17
|
-
attr_reader :ref
|
18
|
-
|
19
|
-
# @!attribute [rw] repository
|
20
|
-
# @return [R10K::Git::Repository] A git repository that can be used to
|
21
|
-
# resolve the git reference to a commit.
|
22
|
-
attr_accessor :repository
|
23
|
-
|
24
|
-
def initialize(ref, repository = nil)
|
25
|
-
@ref = ref
|
26
|
-
@repository = repository
|
27
|
-
end
|
28
|
-
|
29
|
-
# Can we locate the commit in the related repository?
|
30
|
-
def resolvable?
|
31
|
-
sha1
|
32
|
-
true
|
33
|
-
rescue R10K::Git::UnresolvableRefError
|
34
|
-
false
|
35
|
-
end
|
36
|
-
|
37
|
-
# Should we try to fetch this ref?
|
38
|
-
#
|
39
|
-
# Since we don't know the type of this ref, we have to assume that it might
|
40
|
-
# be a branch and always update accordingly.
|
41
|
-
def fetch?
|
42
|
-
true
|
43
|
-
end
|
44
|
-
|
45
|
-
def sha1
|
46
|
-
if @repository.nil?
|
47
|
-
raise ArgumentError, "Cannot resolve #{self.inspect}: no associated git repository"
|
48
|
-
else
|
49
|
-
@repository.rev_parse(ref)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def ==(other)
|
54
|
-
other.is_a?(R10K::Git::Ref) && other.sha1 == self.sha1
|
55
|
-
rescue ArgumentError, R10K::Git::UnresolvableRefError
|
56
|
-
false
|
57
|
-
end
|
58
|
-
|
59
|
-
def to_s
|
60
|
-
ref
|
61
|
-
end
|
62
|
-
|
63
|
-
def inspect
|
64
|
-
"#<#{self.class}: #{to_s}>"
|
65
|
-
end
|
66
|
-
end
|
data/lib/r10k/git/remote_head.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'r10k/git'
|
2
|
-
|
3
|
-
# :nocov:
|
4
|
-
#
|
5
|
-
# @deprecated This has been replaced by the ShellGit provider and the
|
6
|
-
# StatefulRepository class and will be removed in 2.0.0
|
7
|
-
#
|
8
|
-
# @api private
|
9
|
-
class R10K::Git::RemoteHead < R10K::Git::Head
|
10
|
-
|
11
|
-
def sha1
|
12
|
-
if @repository.nil?
|
13
|
-
raise ArgumentError, "Cannot resolve #{self.inspect}: no associated git repository"
|
14
|
-
else
|
15
|
-
@repository.resolve_head("refs/remotes/cache/#{@head}")
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
# :nocov:
|
data/lib/r10k/git/repository.rb
DELETED
@@ -1,158 +0,0 @@
|
|
1
|
-
require 'r10k/git'
|
2
|
-
require 'r10k/util/subprocess'
|
3
|
-
|
4
|
-
# Define an abstract base class for git repositories.
|
5
|
-
#
|
6
|
-
# @deprecated This has been replaced by the ShellGit provider and the
|
7
|
-
# StatefulRepository class and will be removed in 2.0.0
|
8
|
-
#
|
9
|
-
# :nocov:
|
10
|
-
class R10K::Git::Repository
|
11
|
-
|
12
|
-
# @!attribute [r] remote
|
13
|
-
# @return [String] The URL to the git repository
|
14
|
-
attr_reader :remote
|
15
|
-
|
16
|
-
# @!attribute [r] basedir
|
17
|
-
# @return [String] The directory containing the repository
|
18
|
-
attr_reader :basedir
|
19
|
-
|
20
|
-
# @!attribute [r] dirname
|
21
|
-
# @return [String] The name of the directory
|
22
|
-
attr_reader :dirname
|
23
|
-
|
24
|
-
# @!attribute [r] git_dir
|
25
|
-
# Set the path to the git directory. For git repositories with working copies
|
26
|
-
# this will be `$working_dir/.git`; for bare repositories this will be
|
27
|
-
# `bare-repo.git`
|
28
|
-
# @return [String] The path to the git directory
|
29
|
-
attr_reader :git_dir
|
30
|
-
|
31
|
-
# Resolve a ref to a git commit. The given pattern can be a commit, tag,
|
32
|
-
# or a local or remote branch
|
33
|
-
#
|
34
|
-
# @param [String] pattern
|
35
|
-
#
|
36
|
-
# @return [String] The dereferenced hash of `pattern`
|
37
|
-
def resolve_ref(pattern)
|
38
|
-
commit = resolve_tag(pattern)
|
39
|
-
commit ||= resolve_remote_head(pattern)
|
40
|
-
commit ||= resolve_head(pattern)
|
41
|
-
commit ||= resolve_commit(pattern)
|
42
|
-
|
43
|
-
if commit
|
44
|
-
commit.chomp
|
45
|
-
else
|
46
|
-
raise R10K::Git::UnresolvableRefError.new("Could not resolve Git ref '#{ref}'", :ref => pattern, :git_dir => git_dir)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
alias rev_parse resolve_ref
|
50
|
-
|
51
|
-
def resolve_tag(pattern)
|
52
|
-
output = git ['show-ref', '--tags', '-s', pattern], :git_dir => git_dir, :raise_on_fail => false
|
53
|
-
|
54
|
-
if output.success?
|
55
|
-
output.stdout.lines.first
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def resolve_head(pattern)
|
60
|
-
output = git ['show-ref', '--heads', '-s', pattern], :git_dir => git_dir, :raise_on_fail => false
|
61
|
-
|
62
|
-
if output.success?
|
63
|
-
output.stdout.lines.first
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def resolve_remote_head(pattern, remote = 'origin')
|
68
|
-
pattern = "refs/remotes/#{remote}/#{pattern}"
|
69
|
-
output = git ['show-ref', '-s', pattern], :git_dir => git_dir, :raise_on_fail => false
|
70
|
-
|
71
|
-
if output.success?
|
72
|
-
output.stdout.lines.first
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
# Define the same interface for resolving refs.
|
77
|
-
def resolve_commit(pattern)
|
78
|
-
output = git ['rev-parse', "#{pattern}^{commit}"], :git_dir => git_dir, :raise_on_fail => false
|
79
|
-
|
80
|
-
if output.success?
|
81
|
-
output.stdout.chomp
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
# @return [Hash<String, String>] A hash of remote names and fetch URLs
|
86
|
-
# @api private
|
87
|
-
def remotes
|
88
|
-
output = git ['remote', '-v'], :git_dir => git_dir
|
89
|
-
|
90
|
-
ret = {}
|
91
|
-
output.stdout.each_line do |line|
|
92
|
-
next if line.match(/\(push\)/)
|
93
|
-
name, url, _ = line.split(/\s+/)
|
94
|
-
ret[name] = url
|
95
|
-
end
|
96
|
-
|
97
|
-
ret
|
98
|
-
end
|
99
|
-
|
100
|
-
def tags
|
101
|
-
entries = []
|
102
|
-
output = git(['tag', '-l'], :git_dir => @git_dir).stdout
|
103
|
-
output.each_line { |line| entries << line.chomp }
|
104
|
-
entries
|
105
|
-
end
|
106
|
-
|
107
|
-
private
|
108
|
-
|
109
|
-
# Fetch objects and refs from the given git remote
|
110
|
-
#
|
111
|
-
# @param remote [#to_s] The remote name to fetch from
|
112
|
-
def fetch(remote = 'origin')
|
113
|
-
git ['fetch', '--prune', remote], :git_dir => @git_dir
|
114
|
-
end
|
115
|
-
|
116
|
-
# Wrap git commands
|
117
|
-
#
|
118
|
-
# @param cmd [Array<String>] cmd The arguments for the git prompt
|
119
|
-
# @param opts [Hash] opts
|
120
|
-
#
|
121
|
-
# @option opts [String] :path
|
122
|
-
# @option opts [String] :git_dir
|
123
|
-
# @option opts [String] :work_tree
|
124
|
-
# @option opts [String] :raise_on_fail
|
125
|
-
#
|
126
|
-
# @raise [R10K::ExecutionFailure] If the executed command exited with a
|
127
|
-
# nonzero exit code.
|
128
|
-
#
|
129
|
-
# @return [String] The git command output
|
130
|
-
def git(cmd, opts = {})
|
131
|
-
raise_on_fail = opts.fetch(:raise_on_fail, true)
|
132
|
-
|
133
|
-
argv = %w{git}
|
134
|
-
|
135
|
-
if opts[:path]
|
136
|
-
argv << "--git-dir" << File.join(opts[:path], '.git')
|
137
|
-
argv << "--work-tree" << opts[:path]
|
138
|
-
else
|
139
|
-
if opts[:git_dir]
|
140
|
-
argv << "--git-dir" << opts[:git_dir]
|
141
|
-
end
|
142
|
-
if opts[:work_tree]
|
143
|
-
argv << "--work-tree" << opts[:work_tree]
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
argv.concat(cmd)
|
148
|
-
|
149
|
-
subproc = R10K::Util::Subprocess.new(argv)
|
150
|
-
subproc.raise_on_fail = raise_on_fail
|
151
|
-
subproc.logger = self.logger
|
152
|
-
|
153
|
-
result = subproc.execute
|
154
|
-
|
155
|
-
result
|
156
|
-
end
|
157
|
-
end
|
158
|
-
# :nocov:
|