Skip to content

Commit 24f2b42

Browse files
Raj Nandan SharmaRaj Nandan Sharma
Raj Nandan Sharma
authored and
Raj Nandan Sharma
committed
fix(cmd): fixed pull cmd
1 parent 10c7da8 commit 24f2b42

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed

cmd/pull.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,7 @@ var pullCmd = &cobra.Command{
4141

4242
gitPull := models.AllCommands["gitPull"]
4343
gitPull.Arguments = append(gitPull.Arguments, string(branch))
44-
cmdOut, cmdErr = utils.RunCommand(gitPull.Name, gitPull.Arguments, "")
45-
if cmdErr != nil {
46-
utils.LogFatal(cmdErr)
47-
}
48-
utils.LogOutput(cmdOut)
44+
utils.RunCommand(gitPull.Name, gitPull.Arguments, "")
4945

5046
},
5147
}

cmd/push.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ var pushCmd = &cobra.Command{
1212
Long: "Push local branch changes to remote. Similar to `git push`. Example usage: okgit ps",
1313
Run: func(cmd *cobra.Command, args []string) {
1414

15+
// do a git pull first
16+
pullCmd.Run(cmd, args)
17+
1518
gitPush := models.AllCommands["gitPush"]
1619
cmdOut, cmdErr := utils.RunCommand(gitPush.Name, gitPush.Arguments, "")
1720
if cmdErr != nil {

cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var rootCmd = &cobra.Command{
1717
// Uncomment the following line if your bare application
1818
// has an action associated with it:
1919
// Run: func(cmd *cobra.Command, args []string) { },
20-
Version: "1.0.8",
20+
Version: "1.0.9",
2121
}
2222

2323
// Execute adds all child commands to the root command and sets flags appropriately.

cmd/start.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,19 @@ var startCmd = &cobra.Command{
2626
if err != nil {
2727
utils.LogFatal(err)
2828
}
29-
if len(res) == 0 {
29+
30+
splitRes := strings.Split(res, "\n")
31+
branchPresent := false
32+
for _, line := range splitRes {
33+
trimmed := strings.TrimSpace(line)
34+
trimmed = strings.TrimPrefix(trimmed, "* ")
35+
if trimmed == branch {
36+
branchPresent = true
37+
break
38+
}
39+
}
40+
41+
if !branchPresent {
3042
createBranch := models.AllCommands["createBranch"]
3143
createBranch.Arguments = append(createBranch.Arguments, branch)
3244
cmdOut, cmdErr := utils.RunCommand(createBranch.Name, createBranch.Arguments, "")
@@ -41,11 +53,8 @@ var startCmd = &cobra.Command{
4153
gitPull := models.AllCommands["gitPull"]
4254
gitPull.Arguments = append(gitPull.Arguments, branch)
4355

44-
msg, err1 := utils.RunCommand(gitPull.Name, gitPull.Arguments, "")
45-
if err1 != nil {
46-
utils.LogFatal(err1)
47-
}
48-
utils.LogOutput(msg)
56+
utils.RunCommand(gitPull.Name, gitPull.Arguments, "")
57+
4958
},
5059
}
5160

0 commit comments

Comments
 (0)