Class: Avm::Git::Scms::Git::Commit

Inherits:
Scms::Commit
  • Object
show all
Defined in:
lib/avm/git/scms/git/commit.rb,
lib/avm/git/scms/git/commit/deploy.rb,
lib/avm/git/scms/git/commit/deploy_methods.rb

Defined Under Namespace

Modules: DeployMethods Classes: Deploy

Constant Summary collapse

FIXUP_SUBJECT_PATTERN =
/\Afixup!/.freeze

Instance Method Summary collapse

Instance Method Details

#changed_filesArray<Pathname>

Returns:

  • (Array<Pathname>)


18
19
20
# File 'lib/avm/git/scms/git/commit.rb', line 18

def changed_files
  git_commit.changed_files.map { |cf| cf.path.to_pathname }
end

#fixup?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/avm/git/scms/git/commit.rb', line 23

def fixup?
  FIXUP_SUBJECT_PATTERN.match?(git_commit.subject)
end

#merge_with(other) ⇒ Avm::Git::Scms::Git::Commit



29
30
31
32
33
34
35
# File 'lib/avm/git/scms/git/commit.rb', line 29

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

#reword(new_message) ⇒ Object



37
38
39
40
41
42
# File 'lib/avm/git/scms/git/commit.rb', line 37

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

#scm_file?(path) ⇒ TrueClass, FalseClass

Parameters:

  • path (Pathname)

Returns:

  • (TrueClass, FalseClass)


46
47
48
# File 'lib/avm/git/scms/git/commit.rb', line 46

def scm_file?(path)
  %w[.gitrepo .gitmodules].any? { |file| file.include?(path.basename.to_path) }
end

#subjectString

Returns:

  • (String)


51
# File 'lib/avm/git/scms/git/commit.rb', line 51

delegate :subject, to: :git_commit