Skip to content

Commit

Permalink
fixing git stash to include untracked files
Browse files Browse the repository at this point in the history
  • Loading branch information
emersonmello committed Sep 22, 2022
1 parent 2fe4ec5 commit 65d0c8f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var (
rootCmd = &cobra.Command{
Use: "claro",
Short: "A GitHub Classroom CLI for teachers",
Version: "0.1.1",
Version: "0.1.2",
}
)

Expand Down
21 changes: 14 additions & 7 deletions utils/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,23 @@ func Pull(files []fs.DirEntry, directory string) {
for _, f := range files {
if f.IsDir() {
p.UpdateTitle("Pull " + f.Name())
execGitCommands("stash")
cmd := exec.Command("git", "pull", "--rebase")
cmd := exec.Command("git", "stash", "--include-untracked")
cmd.Dir = f.Name()
_, err := cmd.CombinedOutput()
err := cmd.Run()
if err != nil {
pterm.Error.Println(f.Name() + " is not clean!")
pterm.Info.Println(e.Error())
pterm.Error.Println("Could not run git stash command. Is the '" + f.Name() + "' directory a git repository?")
} else {
execGitCommands("stash", "pop")
pterm.Success.Println("Pull " + f.Name())
cmd = exec.Command("git", "pull", "--rebase")
cmd.Dir = f.Name()
err = cmd.Run()
if err != nil {
pterm.Error.Println(f.Name() + " is not clean!")
} else {
cmd := exec.Command("git", "stash", "pop")
cmd.Dir = f.Name()
_ = cmd.Run()
pterm.Success.Println("Pull " + f.Name())
}
}
}
}
Expand Down

0 comments on commit 65d0c8f

Please sign in to comment.