fix unsafe concurrent access to git repo

This commit is contained in:
Tim Schubert 2022-05-23 18:07:09 +02:00
parent f07bae94fb
commit bd0ba1bf5e
Signed by: dadada
GPG key ID: EEB8D1CE62C4DFEA

View file

@ -33,6 +33,10 @@ func commit(
commitmu.Lock()
defer commitmu.Unlock()
if _, err := tree.Add(padfile); err != nil {
return plumbing.ZeroHash, fmt.Errorf("Failed to stage %s: %w", padfile, err)
}
commit, err := tree.Commit(
fmt.Sprintf("Updated %s from %s", padfile, url),
&git.CommitOptions{
@ -85,10 +89,6 @@ func update(
return plumbing.ZeroHash, fmt.Errorf("No changes recorded for %s", url)
}
if _, err = tree.Add(padfile); err != nil {
return plumbing.ZeroHash, fmt.Errorf("Failed to stage %s: %w", padfile, err)
}
return commit(tree, padfile, url)
}