Skip to content

Commit

Permalink
Add also cleaning all changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mikusaq committed Nov 7, 2024
1 parent ac7e395 commit fb50fe3
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions modules/bringauto_repository/GitLFSRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,17 @@ func (lfs *GitLFSRepository) CommitAllChanges() error {
return nil
}

// RestoreAllChanges
// Restores all changes in repository and cleans all untracked changes.
func (lfs *GitLFSRepository) RestoreAllChanges() error {
err := lfs.gitRestoreAll()
if err != nil {
return err
}
err = lfs.gitCleanAll()
if err != nil {
return err
}
return nil
}

Expand Down Expand Up @@ -241,6 +247,19 @@ func (lfs *GitLFSRepository) gitRestoreAll() error {
return nil
}

func (lfs *GitLFSRepository) gitCleanAll() error {
var ok, _ = lfs.prepareAndRun([]string{
"clean",
"-f",
".",
},
)
if !ok {
return fmt.Errorf("cannot clean changes")
}
return nil
}

func (repo *GitLFSRepository) prepareAndRun(cmdline []string) (bool, *bytes.Buffer) {
var cmd exec.Cmd
var outBuffer bytes.Buffer
Expand Down

0 comments on commit fb50fe3

Please sign in to comment.