Module: Kubernetes::Release::PublishGuard
- Defined in:
- lib/kubernetes/release/publish_guard.rb
Class Method Summary collapse
- .capture_command(*command) ⇒ Object
- .gemspec_files(gemspec_path) ⇒ Object
- .package_file_repo_path(repo_root:, package_root:, package_path:) ⇒ Object
- .untracked_gemspec_files(repo_root:, package_root:, gemspec_path:) ⇒ Object
- .untracked_package_files(repo_root:, package_root:, package_files:) ⇒ Object
Class Method Details
.capture_command(*command) ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/kubernetes/release/publish_guard.rb', line 52 def capture_command(*command) output, status = Open3.capture2e(*command) return output if status.success? = "command failed: #{Shellwords.join(command)}" details = output.strip = "#{}\n#{details}" unless details.empty? raise Changelog::Error, end |
.gemspec_files(gemspec_path) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/kubernetes/release/publish_guard.rb', line 13 def gemspec_files(gemspec_path) spec = Gem::Specification.load(gemspec_path) raise Changelog::Error, "failed to load gemspec #{gemspec_path}" unless spec spec.files rescue Gem::InvalidSpecificationException => e raise Changelog::Error, e. end |
.package_file_repo_path(repo_root:, package_root:, package_path:) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/kubernetes/release/publish_guard.rb', line 40 def package_file_repo_path(repo_root:, package_root:, package_path:) repo_root = File.(repo_root) repo_prefix = "#{repo_root}#{File::SEPARATOR}" full_path = File.(package_path, package_root) unless full_path.start_with?(repo_prefix) raise Changelog::Error, "gem package file #{package_path} resolves outside #{repo_root}" end full_path.delete_prefix(repo_prefix) end |
.untracked_gemspec_files(repo_root:, package_root:, gemspec_path:) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/kubernetes/release/publish_guard.rb', line 32 def untracked_gemspec_files(repo_root:, package_root:, gemspec_path:) untracked_package_files( repo_root: repo_root, package_root: package_root, package_files: gemspec_files(gemspec_path) ) end |
.untracked_package_files(repo_root:, package_root:, package_files:) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/kubernetes/release/publish_guard.rb', line 22 def untracked_package_files(repo_root:, package_root:, package_files:) repo_paths = package_files.map do |path| package_file_repo_path(repo_root: repo_root, package_root: package_root, package_path: path) end.uniq.sort return [] if repo_paths.empty? tracked_paths = capture_command("git", "-C", repo_root, "ls-files", "--", *repo_paths).lines.map(&:chomp) repo_paths - tracked_paths end |