Class: StiDeploy::Git::Commit

Inherits:
Object
  • Object
show all
Defined in:
lib/sti_deploy/git/commit.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(branch, message) ⇒ Commit

Returns a new instance of Commit.



6
7
8
9
10
# File 'lib/sti_deploy/git/commit.rb', line 6

def initialize(branch, message)
  @branch = branch
  @git_user = Configuration.git_username
  @message = commit_message(git_user, message)
end

Instance Attribute Details

#branchObject (readonly)

Returns the value of attribute branch.



4
5
6
# File 'lib/sti_deploy/git/commit.rb', line 4

def branch
  @branch
end

#git_userObject (readonly)

Returns the value of attribute git_user.



4
5
6
# File 'lib/sti_deploy/git/commit.rb', line 4

def git_user
  @git_user
end

#messageObject (readonly)

Returns the value of attribute message.



4
5
6
# File 'lib/sti_deploy/git/commit.rb', line 4

def message
  @message
end

Instance Method Details

#commit!Object



12
13
14
15
16
17
18
# File 'lib/sti_deploy/git/commit.rb', line 12

def commit!
  Messages.puts('git.committing', color: :yellow)
  Git.add_version
  return true if Git.commit(message: message) && Git.push(branch: branch)
  Messages.puts('git.push_error', target: branch, color: :red)
  exit(4)
end