diff --git a/src/vcs/fake/vcs_test_fake.go b/src/vcs/fake/vcs_test_fake.go index e09e393f..91f7f13e 100644 --- a/src/vcs/fake/vcs_test_fake.go +++ b/src/vcs/fake/vcs_test_fake.go @@ -59,8 +59,6 @@ const ( PushCommand Command = "push" RevertLocalCommand Command = "revertLocal" RollbackLastCommitCommand Command = "rollbackLastCommit" - StashCommand Command = "stash" - UnStashCommand Command = "unStash" ) type ( @@ -162,16 +160,6 @@ func (vf *VCSFake) Log(msgFilter func(msg string) bool) (logs vcs.LogItems, err return } -// Stash does nothing. Returns an error if in the list of failing commands -func (vf *VCSFake) Stash(_ string) error { - return vf.fakeCommand(StashCommand) -} - -// UnStash does nothing. Returns an error if in the list of failing commands -func (vf *VCSFake) UnStash(_ bool) error { - return vf.fakeCommand(UnStashCommand) -} - // RollbackLastCommit does nothing. Returns an error if in the list of failing commands func (vf *VCSFake) RollbackLastCommit() error { return vf.fakeCommand(RollbackLastCommitCommand) diff --git a/src/vcs/git/git_impl.go b/src/vcs/git/git_impl.go index 76a2a0e0..a0cf9328 100644 --- a/src/vcs/git/git_impl.go +++ b/src/vcs/git/git_impl.go @@ -292,25 +292,6 @@ func (g *gitImpl) Pull() error { return g.traceGit("pull", "--no-recurse-submodules", g.GetRemoteName(), g.GetWorkingBranch()) } -// Stash creates a git stash. -// Current implementation uses a direct call to git -func (g *gitImpl) Stash(message string) error { - report.PostInfo("Stashing changes") - return g.traceGit("stash", "push", "--quiet", "--include-untracked", "--message", message) -} - -// UnStash applies a git stash. Depending on the keep argument value, either a "stash apply" or a "stash pop" -// command is executed under the hood. -// Current implementation uses a direct call to git -func (g *gitImpl) UnStash(keep bool) error { - report.PostInfo("Applying stashed changes") - stashAction := "pop" - if keep { - stashAction = "apply" - } - return g.traceGit("stash", stashAction, "--quiet") -} - // Diff returns the list of files modified since last commit with diff info for each file // Current implementation uses a direct call to git func (g *gitImpl) Diff() (diffs vcs.FileDiffs, err error) { diff --git a/src/vcs/git/git_impl_test.go b/src/vcs/git/git_impl_test.go index dec1c884..b6224714 100644 --- a/src/vcs/git/git_impl_test.go +++ b/src/vcs/git/git_impl_test.go @@ -511,106 +511,6 @@ func Test_git_revert(t *testing.T) { } } -func Test_git_stash(t *testing.T) { - testFlags := []struct { - desc string - message string - gitError error - expectError bool - expectedArgs []string - }{ - { - "git stash command call succeeds", - "some message", - nil, - false, - []string{"stash", "push", "--quiet", "--include-untracked", "--message", "some message"}, - }, - { - "git stash command call fails", - "some message", - errors.New("git stash push error"), - true, - []string{"stash", "push", "--quiet", "--include-untracked", "--message", "some message"}, - }, - } - for _, tt := range testFlags { - t.Run(tt.desc, func(t *testing.T) { - var actualArgs []string - g, _ := newGitImpl(inMemoryRepoInit, "") - g.traceGitFunction = func(args ...string) (err error) { - actualArgs = args[2:] - return tt.gitError - } - - err := g.Stash(tt.message) - if tt.expectError { - assert.Error(t, err) - } else { - assert.NoError(t, err) - } - assert.Equal(t, tt.expectedArgs, actualArgs) - }) - } -} - -func Test_git_unstash(t *testing.T) { - testFlags := []struct { - desc string - keep bool - gitError error - expectError bool - expectedArgs []string - }{ - { - "keep stash and git stash command call succeeds", - true, - nil, - false, - []string{"stash", "apply", "--quiet"}, - }, - { - "keep stash and git stash command call fails", - true, - errors.New("git stash apply error"), - true, - []string{"stash", "apply", "--quiet"}, - }, - { - "remove stash and git stash command call succeeds", - false, - nil, - false, - []string{"stash", "pop", "--quiet"}, - }, - { - "remove stash and git stash command call fails", - false, - errors.New("git stash pop error"), - true, - []string{"stash", "pop", "--quiet"}, - }, - } - for _, tt := range testFlags { - t.Run(tt.desc, func(t *testing.T) { - var actualArgs []string - g, _ := newGitImpl(inMemoryRepoInit, "") - g.traceGitFunction = func(args ...string) (err error) { - actualArgs = args[2:] - return tt.gitError - } - - err := g.UnStash(tt.keep) - if tt.expectError { - assert.Error(t, err) - } else { - assert.NoError(t, err) - } - assert.Equal(t, tt.expectedArgs, actualArgs) - }) - } -} - func Test_git_log(t *testing.T) { // Note: this test may break if for any reason the TCR repository initial commit is altered tcrInitialCommit := vcs.LogItem{ diff --git a/src/vcs/p4/p4_impl.go b/src/vcs/p4/p4_impl.go index ff492ebc..068a0913 100644 --- a/src/vcs/p4/p4_impl.go +++ b/src/vcs/p4/p4_impl.go @@ -195,19 +195,6 @@ func (p *p4Impl) Pull() error { return p.traceP4("sync", path) } -// Stash creates a p4 stash. -// TODO: VCS Stash - p4 ??? -func (*p4Impl) Stash(_ string) error { - return errors.New("VCS stash operation not yet available for p4") -} - -// UnStash applies a p4 stash. Depending on the keep argument value, either a "stash apply" or a "stash pop" -// command is executed under the hood. -// TODO: VCS UnStash - p4 ??? -func (*p4Impl) UnStash(_ bool) error { - return errors.New("VCS unstash operation not yet available for p4") -} - // Diff returns the list of files modified since last commit with diff info for each file func (p *p4Impl) Diff() (diffs vcs.FileDiffs, err error) { var p4Output []byte diff --git a/src/vcs/vcs.go b/src/vcs/vcs.go index bce99e2c..65cf00dd 100644 --- a/src/vcs/vcs.go +++ b/src/vcs/vcs.go @@ -61,8 +61,6 @@ type Interface interface { RollbackLastCommit() error Push() error Pull() error - Stash(message string) error - UnStash(keep bool) error Diff() (diffs FileDiffs, err error) Log(msgFilter func(msg string) bool) (logs LogItems, err error) EnableAutoPush(flag bool)