fix unsafe concurrent access to git repo
This commit is contained in:
parent
f07bae94fb
commit
bd0ba1bf5e
1 changed files with 4 additions and 4 deletions
8
main.go
8
main.go
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue