Skip to content
Snippets Groups Projects
Unverified Commit 7df52035 authored by Sébastien Gaya's avatar Sébastien Gaya Committed by GitHub
Browse files

Progression des sub batchs (#1971)

* sub batch progress

* progress if multiple sub commits

* Refactor des sub batchs (#1972)

* sub batch refactor

* fix
parent 27a6a449
No related branches found
No related tags found
No related merge requests found
......@@ -81,16 +81,23 @@ class Git::Providers::Github < Git::Providers::Abstract
base_tree_sha = tree[:sha]
base_commit_sha = branch_sha
commit = nil
batch.each_slice(COMMIT_BATCH_SIZE) do |sub_batch|
puts "Creating commit with #{sub_batch.size} files."
new_tree = client.create_tree repository, sub_batch, base_tree: base_tree_sha
commit = client.create_commit repository, commit_message, new_tree[:sha], base_commit_sha
base_tree_sha = new_tree[:sha]
commits_count = (batch.size / COMMIT_BATCH_SIZE.to_f).ceil
batch.each_slice(COMMIT_BATCH_SIZE).with_index do |sub_batch, i|
sub_commit_message = commit_message
sub_commit_message += " (#{i+1}/#{commits_count})" if commits_count > 1
commit = create_sub_commit(sub_batch, sub_commit_message, base_tree_sha, base_commit_sha)
base_tree_sha = commit[:tree][:sha]
base_commit_sha = commit[:sha]
end
commit
end
def create_sub_commit(sub_batch, sub_commit_message, base_tree_sha, base_commit_sha)
puts "Creating commit with #{sub_batch.size} files."
new_tree = client.create_tree repository, sub_batch, base_tree: base_tree_sha
client.create_commit repository, sub_commit_message, new_tree[:sha], base_commit_sha
end
def computed_sha(string)
# Git SHA-1 is calculated from the String "blob <length>\x00<contents>"
# Source: https://alblue.bandlem.com/2011/08/git-tip-of-week-objects.html
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment