summaryrefslogtreecommitdiffstats
path: root/pkg/commands
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/commands')
-rw-r--r--pkg/commands/dummies.go2
-rw-r--r--pkg/commands/git.go10
-rw-r--r--pkg/commands/git_test.go14
-rw-r--r--pkg/commands/loading_commits.go6
-rw-r--r--pkg/commands/loading_commits_test.go2
-rw-r--r--pkg/commands/patch_rebases.go4
-rw-r--r--pkg/commands/pull_request.go4
-rw-r--r--pkg/commands/rebasing.go8
8 files changed, 24 insertions, 26 deletions
diff --git a/pkg/commands/dummies.go b/pkg/commands/dummies.go
index da03d2f08..b7ec98501 100644
--- a/pkg/commands/dummies.go
+++ b/pkg/commands/dummies.go
@@ -17,7 +17,7 @@ func NewDummyGitCommandWithOSCommand(osCommand *oscommands.OSCommand) *GitComman
return &GitCommand{
Log: utils.NewDummyLog(),
OSCommand: osCommand,
- Tr: i18n.NewLocalizer(utils.NewDummyLog()),
+ Tr: i18n.NewTranslationSet(utils.NewDummyLog()),
Config: config.NewDummyAppConfig(),
getGlobalGitConfig: func(string) (string, error) { return "", nil },
getLocalGitConfig: func(string) (string, error) { return "", nil },
diff --git a/pkg/commands/git.go b/pkg/commands/git.go
index af1533886..63b0e6859 100644
--- a/pkg/commands/git.go
+++ b/pkg/commands/git.go
@@ -30,7 +30,7 @@ type GitCommand struct {
Log *logrus.Entry
OSCommand *oscommands.OSCommand
Repo *gogit.Repository
- Tr *i18n.Localizer
+ Tr *i18n.TranslationSet
Config config.AppConfigurer
getGlobalGitConfig func(string) (string, error)
getLocalGitConfig func(string) (string, error)
@@ -44,7 +44,7 @@ type GitCommand struct {
}
// NewGitCommand it runs git commands
-func NewGitCommand(log *logrus.Entry, osCommand *oscommands.OSCommand, tr *i18n.Localizer, config config.AppConfigurer) (*GitCommand, error) {
+func NewGitCommand(log *logrus.Entry, osCommand *oscommands.OSCommand, tr *i18n.TranslationSet, config config.AppConfigurer) (*GitCommand, error) {
var repo *gogit.Repository
// see what our default push behaviour is
@@ -64,7 +64,7 @@ func NewGitCommand(log *logrus.Entry, osCommand *oscommands.OSCommand, tr *i18n.
return nil, err
}
- if repo, err = setupRepository(gogit.PlainOpen, tr.SLocalize); err != nil {
+ if repo, err = setupRepository(gogit.PlainOpen, tr.GitconfigParseErr); err != nil {
return nil, err
}
@@ -140,7 +140,7 @@ func resolvePath(path string) (string, error) {
return filepath.EvalSymlinks(path)
}
-func setupRepository(openGitRepository func(string) (*gogit.Repository, error), sLocalize func(string) string) (*gogit.Repository, error) {
+func setupRepository(openGitRepository func(string) (*gogit.Repository, error), gitConfigParseErrorStr string) (*gogit.Repository, error) {
unresolvedPath := env.GetGitDirEnv()
if unresolvedPath == "" {
var err error
@@ -159,7 +159,7 @@ func setupRepository(openGitRepository func(string) (*gogit.Repository, error),
if err != nil {
if strings.Contains(err.Error(), `unquoted '\' must be followed by new line`) {
- return nil, errors.New(sLocalize("GitconfigParseErr"))
+ return nil, errors.New(gitConfigParseErrorStr)
}
return nil, err
diff --git a/pkg/commands/git_test.go b/pkg/commands/git_test.go
index e04903e39..ebac76e01 100644
--- a/pkg/commands/git_test.go
+++ b/pkg/commands/git_test.go
@@ -159,7 +159,7 @@ func TestSetupRepository(t *testing.T) {
type scenario struct {
testName string
openGitRepository func(string) (*gogit.Repository, error)
- sLocalize func(string) string
+ errorStr string
test func(*gogit.Repository, error)
}
@@ -169,9 +169,7 @@ func TestSetupRepository(t *testing.T) {
func(string) (*gogit.Repository, error) {
return nil, fmt.Errorf(`unquoted '\' must be followed by new line`)
},
- func(string) string {
- return "error translated"
- },
+ "error translated",
func(r *gogit.Repository, err error) {
assert.Error(t, err)
assert.EqualError(t, err, "error translated")
@@ -182,7 +180,7 @@ func TestSetupRepository(t *testing.T) {
func(string) (*gogit.Repository, error) {
return nil, fmt.Errorf("Error from inside gogit")
},
- func(string) string { return "" },
+ "",
func(r *gogit.Repository, err error) {
assert.Error(t, err)
assert.EqualError(t, err, "Error from inside gogit")
@@ -196,7 +194,7 @@ func TestSetupRepository(t *testing.T) {
assert.NoError(t, err)
return r, nil
},
- func(string) string { return "" },
+ "",
func(r *gogit.Repository, err error) {
assert.NoError(t, err)
assert.NotNil(t, r)
@@ -206,7 +204,7 @@ func TestSetupRepository(t *testing.T) {
for _, s := range scenarios {
t.Run(s.testName, func(t *testing.T) {
- s.test(setupRepository(s.openGitRepository, s.sLocalize))
+ s.test(setupRepository(s.openGitRepository, s.errorStr))
})
}
}
@@ -254,7 +252,7 @@ func TestNewGitCommand(t *testing.T) {
for _, s := range scenarios {
t.Run(s.testName, func(t *testing.T) {
s.setup()
- s.test(NewGitCommand(utils.NewDummyLog(), oscommands.NewDummyOSCommand(), i18n.NewLocalizer(utils.NewDummyLog()), config.NewDummyAppConfig()))
+ s.test(NewGitCommand(utils.NewDummyLog(), oscommands.NewDummyOSCommand(), i18n.NewTranslationSet(utils.NewDummyLog()), config.NewDummyAppConfig()))
})
}
}
diff --git a/pkg/commands/loading_commits.go b/pkg/commands/loading_commits.go
index 72946aeb6..33954b23e 100644
--- a/pkg/commands/loading_commits.go
+++ b/pkg/commands/loading_commits.go
@@ -33,11 +33,11 @@ type CommitListBuilder struct {
Log *logrus.Entry
GitCommand *GitCommand
OSCommand *oscommands.OSCommand
- Tr *i18n.Localizer
+ Tr *i18n.TranslationSet
}
// NewCommitListBuilder builds a new commit list builder
-func NewCommitListBuilder(log *logrus.Entry, gitCommand *GitCommand, osCommand *oscommands.OSCommand, tr *i18n.Localizer) *CommitListBuilder {
+func NewCommitListBuilder(log *logrus.Entry, gitCommand *GitCommand, osCommand *oscommands.OSCommand, tr *i18n.TranslationSet) *CommitListBuilder {
return &CommitListBuilder{
Log: log,
GitCommand: gitCommand,
@@ -170,7 +170,7 @@ func (c *CommitListBuilder) GetCommits(opts GetCommitsOptions) ([]*models.Commit
if rebaseMode != "" {
currentCommit := commits[len(rebasingCommits)]
blue := color.New(color.FgYellow)
- youAreHere := blue.Sprintf("<-- %s ---", c.Tr.SLocalize("YouAreHere"))
+ youAreHere := blue.Sprintf("<-- %s ---", c.Tr.YouAreHere)
currentCommit.Name = fmt.Sprintf("%s %s", youAreHere, currentCommit.Name)
}
diff --git a/pkg/commands/loading_commits_test.go b/pkg/commands/loading_commits_test.go
index beda2c574..c6c77f259 100644
--- a/pkg/commands/loading_commits_test.go
+++ b/pkg/commands/loading_commits_test.go
@@ -18,7 +18,7 @@ func NewDummyCommitListBuilder() *CommitListBuilder {
Log: utils.NewDummyLog(),
GitCommand: NewDummyGitCommandWithOSCommand(osCommand),
OSCommand: osCommand,
- Tr: i18n.NewLocalizer(utils.NewDummyLog()),
+ Tr: i18n.NewTranslationSet(utils.NewDummyLog()),
}
}
diff --git a/pkg/commands/patch_rebases.go b/pkg/commands/patch_rebases.go
index c51a24ed7..42e03f1e9 100644
--- a/pkg/commands/patch_rebases.go
+++ b/pkg/commands/patch_rebases.go
@@ -72,7 +72,7 @@ func (c *GitCommand) MovePatchToSelectedCommit(commits []*models.Commit, sourceC
// one where we handle the possibility of a credential request, and the other
// where we continue the rebase
if c.usingGpg() {
- return errors.New(c.Tr.SLocalize("DisabledForGPG"))
+ return errors.New(c.Tr.DisabledForGPG)
}
baseIndex := sourceCommitIdx + 1
@@ -139,7 +139,7 @@ func (c *GitCommand) MovePatchToSelectedCommit(commits []*models.Commit, sourceC
func (c *GitCommand) PullPatchIntoIndex(commits []*models.Commit, commitIdx int, p *patch.PatchManager, stash bool) error {
if stash {
- if err := c.StashSave(c.Tr.SLocalize("StashPrefix") + commits[commitIdx].Sha); err != nil {
+ if err := c.StashSave(c.Tr.StashPrefix + commits[commitIdx].Sha); err != nil {
return err
}
}
diff --git a/pkg/commands/pull_request.go b/pkg/commands/pull_request.go
index acceced52..3a820dbfd 100644
--- a/pkg/commands/pull_request.go
+++ b/pkg/commands/pull_request.go
@@ -94,7 +94,7 @@ func (pr *PullRequest) Create(branch *models.Branch) error {
branchExistsOnRemote := pr.GitCommand.CheckRemoteBranchExists(branch)
if !branchExistsOnRemote {
- return errors.New(pr.GitCommand.Tr.SLocalize("NoBranchOnRemote"))
+ return errors.New(pr.GitCommand.Tr.NoBranchOnRemote)
}
repoURL := pr.GitCommand.GetRemoteURL()
@@ -108,7 +108,7 @@ func (pr *PullRequest) Create(branch *models.Branch) error {
}
if gitService == nil {
- return errors.New(pr.GitCommand.Tr.SLocalize("UnsupportedGitService"))
+ return errors.New(pr.GitCommand.Tr.UnsupportedGitService)
}
repoInfo := getRepoInfoFromURL(repoURL)
diff --git a/pkg/commands/rebasing.go b/pkg/commands/rebasing.go
index df1f43607..e7c28bd8d 100644
--- a/pkg/commands/rebasing.go
+++ b/pkg/commands/rebasing.go
@@ -26,7 +26,7 @@ func (c *GitCommand) MoveCommitDown(commits []*models.Commit, index int) error {
// we must ensure that we have at least two commits after the selected one
if len(commits) <= index+2 {
// assuming they aren't picking the bottom commit
- return errors.New(c.Tr.SLocalize("NoRoom"))
+ return errors.New(c.Tr.NoRoom)
}
todo := ""
@@ -101,14 +101,14 @@ func (c *GitCommand) GenerateGenericRebaseTodo(commits []*models.Commit, actionI
baseIndex := actionIndex + 1
if len(commits) <= baseIndex {
- return "", "", errors.New(c.Tr.SLocalize("CannotRebaseOntoFirstCommit"))
+ return "", "", errors.New(c.Tr.CannotRebaseOntoFirstCommit)
}
if action == "squash" || action == "fixup" {
baseIndex++
if len(commits) <= baseIndex {
- return "", "", errors.New(c.Tr.SLocalize("CannotSquashOntoSecondCommit"))
+ return "", "", errors.New(c.Tr.CannotSquashOntoSecondCommit)
}
}
@@ -212,7 +212,7 @@ func (c *GitCommand) BeginInteractiveRebaseForCommit(commits []*models.Commit, c
// one where we handle the possibility of a credential request, and the other
// where we continue the rebase
if c.usingGpg() {
- return errors.New(c.Tr.SLocalize("DisabledForGPG"))
+ return errors.New(c.Tr.DisabledForGPG)
}
todo, sha, err := c.GenerateGenericRebaseTodo(commits, commitIndex, "edit")