Class: Octofart::Tasks::Commits

Inherits:
Object
  • Object
show all
Defined in:
lib/octofart/tasks/commits.rb

Instance Method Summary collapse

Instance Method Details

#run(params) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/octofart/tasks/commits.rb', line 5

def run(params)
  params[:repositories].each_pair do |repo_name, |
    [:tasks].each do |task|
      tree_sha = new_tree_sha(repo_name, task[:path], task[:blob_sha], [:head_branch][:sha])

      commit_args = [
        repo_name,
        task[:message],
        tree_sha,
        [:head_branch][:sha]
      ]

      commit = Octofart.client.create_commit(*commit_args)
      [:head_branch][:sha] = commit.sha # update the commit to latest
    end
  end

  params
end