Class: DeployChanges::Commit

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo) ⇒ Commit

Returns a new instance of Commit.



5
6
7
# File 'lib/deploy_changes/commit.rb', line 5

def initialize(repo)
  @repo = repo
end

Instance Attribute Details

#repoObject (readonly)

Returns the value of attribute repo.



3
4
5
# File 'lib/deploy_changes/commit.rb', line 3

def repo
  @repo
end

Instance Method Details

#last_commitObject



17
18
19
20
21
# File 'lib/deploy_changes/commit.rb', line 17

def last_commit
  return unless File.exist?(last_deploy_commit_file)

  File.read(last_deploy_commit_file).strip
end

#write_head!(sha1 = nil) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/deploy_changes/commit.rb', line 9

def write_head!(sha1 = nil)
  system("mkdir -p #{dir}")

  sha1 ||= repo.head.target_id

  File.write(last_deploy_commit_file, sha1)
end