-
Notifications
You must be signed in to change notification settings - Fork 845
Open
Description
hello,
I use your library to improve automatic update on my local infrastructure.
I check for some docker image release and commit image in a new dedicated branch.
so my workflow is following:
- create a branch
- modify targeting file
- checkout with keep option enable
- add and commit file
- checkout on master without keep option
but in the case where I have another file modify in the worktree who are not commit by my worklow I have a weird behavior when I come back on my main branch file commited in the last commit are always in staging zone.
in a normal git behavor once i Checkout on main branch I need just to have the file modify but not staged and nothing else in the stage zone.
code is the following for information
func (g *GitFileUpdater) CommitImage(image *dockerImage.DockerImage) bool {
slog.Debug(fmt.Sprintf("commit of image %s in file %s", g.File.Path, image.Name))
w, err := g.GitUpdater.Repository.Worktree()
if err != nil {
slog.Error(err.Error())
return false
}
err = w.Checkout(&git.CheckoutOptions{
Branch: g.Branch.Name(), Keep: true,
})
if err != nil {
slog.Error(err.Error(), "stage", "Checkout")
return false
}
_, err = w.Add(g.File.Path)
if err != nil {
slog.Error(err.Error(), "stage", "add")
return false
}
commitmsg := fmt.Sprintf("update (%s): %s to %s", g.File.GetFileName(), image.Name, image.NewTag)
_, err = w.Commit(commitmsg, &git.CommitOptions{
Author: &object.Signature{
Name: "nomad-image-updater",
Email: "",
When: time.Now(),
},
})
if err != nil {
slog.Error(err.Error(), "stage", "commit")
return false
}
w.Checkout(&git.CheckoutOptions{
Branch: g.GitUpdater.ReferenceBranch,
})
return true
}
Metadata
Metadata
Assignees
Labels
No labels