Skip to content

Commit

Permalink
Fixing issue with go-git add and renamed files
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Attwood committed Dec 2, 2022
1 parent 56fa173 commit d4eac95
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,6 @@ func commitChanges(updatedList PackageList) error {

logrus.Info("Committing changes")

opts := git.AddOptions{
All: true,
}

for _, packageWrapper := range updatedList {
assetsPath := path.Join(
repositoryAssetsDir,
Expand All @@ -433,12 +429,23 @@ func commitChanges(updatedList PackageList) error {
packageWrapper.ParsedVendor,
packageWrapper.Name)

opts.Path = assetsPath
wt.AddWithOptions(&opts)
opts.Path = chartsPath
wt.AddWithOptions(&opts)
opts.Path = packagesPath
wt.AddWithOptions(&opts)
wt.Add(assetsPath)
wt.Add(chartsPath)
wt.Add(packagesPath)

gitStatus, err := wt.Status()
if err != nil {
return err
}

for f, s := range gitStatus {
if s.Worktree == git.Deleted {
_, err = wt.Remove(f)
if err != nil {
return err
}
}
}

}

Expand Down Expand Up @@ -471,6 +478,15 @@ func commitChanges(updatedList PackageList) error {

wt.Commit(commitMessage, &commitOptions)

gitStatus, err := wt.Status()
if err != nil {
return err
}

if !gitStatus.IsClean() {
logrus.Fatal("Git status is not clean")
}

return nil
}

Expand Down

0 comments on commit d4eac95

Please sign in to comment.