Skip to content

Commit

Permalink
[#674] Rename VCS.Revert to RollbackLastCommit
Browse files Browse the repository at this point in the history
To have clearer names for all VCS
- rename interface function
- adapt fake
  • Loading branch information
philou authored and mengdaming committed Oct 1, 2024
1 parent 2d82966 commit 4d8ddb6
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/engine/tcr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ func Test_introspective_variant(t *testing.T) {
})

tcr.revert(*events.ATcrEvent())
assert.Equal(t, []fake.Command{fake.CommitCommand, fake.RevertCommand}, vcsFake.GetLastCommands(2))
assert.Equal(t, []fake.Command{fake.CommitCommand, fake.RollbackLastCommitCommand}, vcsFake.GetLastCommands(2))
}

func Test_tcr_cycle_end_state(t *testing.T) {
Expand Down
26 changes: 13 additions & 13 deletions src/vcs/fake/vcs_test_fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ func (gc Commands) contains(command Command) bool {

// List of supported VCS commands
const (
AddCommand Command = "add"
CommitCommand Command = "commit"
DiffCommand Command = "diff"
LogCommand Command = "log"
PullCommand Command = "pull"
PushCommand Command = "push"
RevertLocalCommand Command = "revertLocal"
RevertCommand Command = "revert"
StashCommand Command = "stash"
UnStashCommand Command = "unStash"
AddCommand Command = "add"
CommitCommand Command = "commit"
DiffCommand Command = "diff"
LogCommand Command = "log"
PullCommand Command = "pull"
PushCommand Command = "push"
RevertLocalCommand Command = "revertLocal"
RollbackLastCommitCommand Command = "rollbackLastCommit"
StashCommand Command = "stash"
UnStashCommand Command = "unStash"
)

type (
Expand Down Expand Up @@ -172,9 +172,9 @@ func (vf *VCSFake) UnStash(_ bool) error {
return vf.fakeCommand(UnStashCommand)
}

// Revert does nothing. Returns an error if in the list of failing commands
func (vf *VCSFake) Revert() error {
return vf.fakeCommand(RevertCommand)
// RollbackLastCommit does nothing. Returns an error if in the list of failing commands
func (vf *VCSFake) RollbackLastCommit() error {
return vf.fakeCommand(RollbackLastCommitCommand)
}

// GetRootDir returns the root directory path
Expand Down
4 changes: 2 additions & 2 deletions src/vcs/git/git_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,9 @@ func (g *gitImpl) RevertLocal(path string) error {
return g.traceGit("checkout", "HEAD", "--", path)
}

// Revert runs a git revert operation.
// RollbackLastCommit runs a git revert operation.
// Current implementation uses a direct call to git
func (g *gitImpl) Revert() error {
func (g *gitImpl) RollbackLastCommit() error {
report.PostInfo("Reverting changes")
return g.traceGit("revert", "--no-gpg-sign", "--no-edit", "HEAD")
}
Expand Down
2 changes: 1 addition & 1 deletion src/vcs/git/git_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ func Test_git_revert(t *testing.T) {
return tt.gitError
}

err := g.Revert()
err := g.RollbackLastCommit()
if tt.expectError {
assert.Error(t, err)
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/vcs/p4/p4_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func (p *p4Impl) RevertLocal(path string) error {

// Revert runs a p4 revert operation.
// TODO: VCS Revert - p4 revert
func (*p4Impl) Revert() error {
func (*p4Impl) RollbackLastCommit() error {
return errors.New("VCS revert operation not yet available for p4")
}

Expand Down
2 changes: 1 addition & 1 deletion src/vcs/vcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ type Interface interface {
Add(paths ...string) error
Commit(amend bool, messages ...string) error
RevertLocal(path string) error
Revert() error
RollbackLastCommit() error
Push() error
Pull() error
Stash(message string) error
Expand Down

0 comments on commit 4d8ddb6

Please sign in to comment.