Skip to content

Commit 809bb4a

Browse files
author
Tobias Meinhardt
committed
More logging for git stash pop
1 parent 3a69afc commit 809bb4a

File tree

5 files changed

+16
-9
lines changed

5 files changed

+16
-9
lines changed

git/gogit_adapter.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package git
22

33
import (
4+
"bytes"
45
"os"
56
"path/filepath"
67
"strings"
@@ -123,8 +124,8 @@ func (a goGitAdapter) Stash() error {
123124
}
124125

125126
// Pop all stashed changes
126-
func (a goGitAdapter) StashPop() error {
127-
return errors.New("not implemented yet")
127+
func (a goGitAdapter) StashPop() (stdout, stderr bytes.Buffer, err error) {
128+
return bytes.Buffer{}, bytes.Buffer{}, errors.New("not implemented yet")
128129
}
129130

130131
// Commit added changes

git/logging.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package git
22

33
import (
4+
"bytes"
45
"time"
56

67
"github.com/go-kit/kit/log"
@@ -74,7 +75,7 @@ func (s loggingService) Stash() (err error) {
7475
}
7576

7677
// Pop all stashed changes
77-
func (s loggingService) StashPop() (err error) {
78+
func (s loggingService) StashPop() (stdout, stderr bytes.Buffer, err error) {
7879
defer func(begin time.Time) {
7980
s.logger.Log("method", "StashPop", "took", time.Since(begin), "err", err)
8081
}(time.Now())

git/native_adapter.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,11 @@ func (a nativeGitAdapter) Stash() error {
9999
}
100100

101101
// Pop all stashed changes
102-
func (a nativeGitAdapter) StashPop() error {
102+
func (a nativeGitAdapter) StashPop() (stdout, stderr bytes.Buffer, err error) {
103103
cmd := a.exec.Command("git stash pop")
104-
var stderr bytes.Buffer
104+
cmd.Stdout = &stdout
105105
cmd.Stderr = &stderr
106-
err := cmd.Run()
107-
return errors.Wrap(err, stderr.String())
106+
return stdout, stderr, cmd.Run()
108107
}
109108

110109
// Commit added changes

git/service.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package git
22

33
import (
4+
"bytes"
5+
46
"github.com/meinto/glow"
57
"github.com/meinto/glow/cmd"
68
)
@@ -14,7 +16,7 @@ type Service interface {
1416
Fetch() error
1517
AddAll() error
1618
Stash() error
17-
StashPop() error
19+
StashPop() (stdout, stderr bytes.Buffer, err error)
1820
Commit(message string) error
1921
Push(setUpstream bool) error
2022
Create(b glow.Branch, skipChecks bool) error

pkg/cli/cmd/push.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package cmd
22

33
import (
4+
"log"
5+
46
"github.com/meinto/glow"
57
"github.com/meinto/glow/pkg/cli/cmd/util"
68
"github.com/spf13/cobra"
@@ -50,7 +52,9 @@ var pushCmd = &cobra.Command{
5052
err = g.Checkout(currentBranch)
5153
util.CheckForError(err, "Checkout")
5254

53-
err = g.StashPop()
55+
stdout, stderr, err := g.StashPop()
56+
log.Println(stdout.String())
57+
log.Println(stderr.String())
5458
util.CheckForError(err, "StashPop")
5559

5660
if pushCmdOptions.CommitMessage != "" {

0 commit comments

Comments
 (0)