Sha256: ada1e0890e3ff97ea262596d8caa38506651475aaa4e9a44d9e601b35629264a
Contents?: true
Size: 1.98 KB
Versions: 59
Compression:
Stored size: 1.98 KB
Contents
# frozen_string_literal: true require 'avm/scms/commit' require 'eac_ruby_utils/core_ext' module Avm module Git module Scms class Git < ::Avm::Scms::Base class Commit < ::Avm::Scms::Commit require_sub __FILE__, include_modules: true common_constructor :git_scm, :git_commit do git_commit.assert_argument(::EacGit::Local::Commit, 'git_commit') end delegate :git_repo, to: :git_scm delegate :id, to: :git_commit FIXUP_SUBJECT_PATTERN = /\Afixup\!/.freeze # @return [Array<Pathname>] def changed_files git_commit.changed_files.map { |cf| cf.path.to_pathname } end # @return [Boolean] def fixup? FIXUP_SUBJECT_PATTERN.match?(git_commit.subject) end # @param other [Avm::Git::Scms::Git::Commit] # @return [Avm::Git::Scms::Git::Commit] def merge_with(other) validate_clean_and_head raise 'Implemented for only if other is parent' unless other.git_commit == git_commit.parent git_scm.reset_and_commit(other.git_commit.parent, other.git_commit.raw_body) end def reword(new_message) validate_clean_and_head git_repo.command('commit', '--amend', '-m', new_message).execute! self.class.new(git_scm, git_repo.head) end # @param path [Pathname] # @return [TrueClass,FalseClass] def scm_file?(path) %w[.gitrepo .gitmodules].any? { |file| file.include?(path.basename.to_path) } end # @return [String] delegate :subject, to: :git_commit private def validate_clean_and_head raise 'Implemented for only if repository is no dirty' if git_repo.dirty? raise 'Implemented for only if self is HEAD' unless git_commit == git_repo.head end end end end end end
Version data entries
59 entries across 59 versions & 2 rubygems