Skip to content

Commit ec62dfb

Browse files
committed
improvements
1 parent 66fc22d commit ec62dfb

File tree

6 files changed

+16
-16
lines changed

6 files changed

+16
-16
lines changed

modules/gitrepo/blame.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ import (
1010
)
1111

1212
func LineBlame(ctx context.Context, repo Repository, revision, file string, line uint) (string, error) {
13-
res, _, err := runCmdString(ctx, repo,
13+
return runCmdString(ctx, repo,
1414
gitcmd.NewCommand("blame").
1515
AddOptionFormat("-L %d,%d", line, line).
1616
AddOptionValues("-p", revision).
1717
AddDashesAndList(file))
18-
return res, err
1918
}

modules/gitrepo/branch.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ func GetBranchCommitID(ctx context.Context, repo Repository, branch string) (str
3636

3737
// SetDefaultBranch sets default branch of repository.
3838
func SetDefaultBranch(ctx context.Context, repo Repository, name string) error {
39-
_, _, err := runCmdString(ctx, repo, gitcmd.NewCommand("symbolic-ref", "HEAD").
39+
_, err := runCmdString(ctx, repo, gitcmd.NewCommand("symbolic-ref", "HEAD").
4040
AddDynamicArguments(git.BranchPrefix+name))
4141
return err
4242
}
4343

4444
// GetDefaultBranch gets default branch of repository.
4545
func GetDefaultBranch(ctx context.Context, repo Repository) (string, error) {
46-
stdout, _, err := runCmdString(ctx, repo, gitcmd.NewCommand("symbolic-ref", "HEAD"))
46+
stdout, err := runCmdString(ctx, repo, gitcmd.NewCommand("symbolic-ref", "HEAD"))
4747
if err != nil {
4848
return "", err
4949
}
@@ -56,7 +56,7 @@ func GetDefaultBranch(ctx context.Context, repo Repository) (string, error) {
5656

5757
// IsReferenceExist returns true if given reference exists in the repository.
5858
func IsReferenceExist(ctx context.Context, repo Repository, name string) bool {
59-
_, _, err := runCmdString(ctx, repo, gitcmd.NewCommand("show-ref", "--verify").AddDashesAndList(name))
59+
_, err := runCmdString(ctx, repo, gitcmd.NewCommand("show-ref", "--verify").AddDashesAndList(name))
6060
return err == nil
6161
}
6262

@@ -76,7 +76,7 @@ func DeleteBranch(ctx context.Context, repo Repository, name string, force bool)
7676
}
7777

7878
cmd.AddDashesAndList(name)
79-
_, _, err := runCmdString(ctx, repo, cmd)
79+
_, err := runCmdString(ctx, repo, cmd)
8080
return err
8181
}
8282

@@ -85,12 +85,12 @@ func CreateBranch(ctx context.Context, repo Repository, branch, oldbranchOrCommi
8585
cmd := gitcmd.NewCommand("branch")
8686
cmd.AddDashesAndList(branch, oldbranchOrCommit)
8787

88-
_, _, err := runCmdString(ctx, repo, cmd)
88+
_, err := runCmdString(ctx, repo, cmd)
8989
return err
9090
}
9191

9292
// RenameBranch rename a branch
9393
func RenameBranch(ctx context.Context, repo Repository, from, to string) error {
94-
_, _, err := runCmdString(ctx, repo, gitcmd.NewCommand("branch", "-m").AddDynamicArguments(from, to))
94+
_, err := runCmdString(ctx, repo, gitcmd.NewCommand("branch", "-m").AddDynamicArguments(from, to))
9595
return err
9696
}

modules/gitrepo/command.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"code.gitea.io/gitea/modules/git/gitcmd"
1010
)
1111

12-
func runCmdString(ctx context.Context, repo Repository, cmd *gitcmd.Command) (string, string, error) { //nolint:unparam // the second return parameter maybe used in the future
13-
return cmd.RunStdString(ctx, &gitcmd.RunOpts{Dir: repoPath(repo)})
12+
func runCmdString(ctx context.Context, repo Repository, cmd *gitcmd.Command) (string, error) {
13+
res, _, err := cmd.RunStdString(ctx, &gitcmd.RunOpts{Dir: repoPath(repo)})
14+
return res, err
1415
}

modules/gitrepo/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
)
1313

1414
func GitConfigGet(ctx context.Context, repo Repository, key string) (string, error) {
15-
result, _, err := runCmdString(ctx, repo, gitcmd.NewCommand("config", "--get").
15+
result, err := runCmdString(ctx, repo, gitcmd.NewCommand("config", "--get").
1616
AddDynamicArguments(key))
1717
if err != nil {
1818
return "", err
@@ -27,7 +27,7 @@ func getRepoConfigLockKey(repoStoragePath string) string {
2727
// GitConfigAdd add a git configuration key to a specific value for the given repository.
2828
func GitConfigAdd(ctx context.Context, repo Repository, key, value string) error {
2929
return globallock.LockAndDo(ctx, getRepoConfigLockKey(repo.RelativePath()), func(ctx context.Context) error {
30-
_, _, err := runCmdString(ctx, repo, gitcmd.NewCommand("config", "--add").
30+
_, err := runCmdString(ctx, repo, gitcmd.NewCommand("config", "--add").
3131
AddDynamicArguments(key, value))
3232
return err
3333
})
@@ -38,7 +38,7 @@ func GitConfigAdd(ctx context.Context, repo Repository, key, value string) error
3838
// If the key exists, it will be updated to the new value.
3939
func GitConfigSet(ctx context.Context, repo Repository, key, value string) error {
4040
return globallock.LockAndDo(ctx, getRepoConfigLockKey(repo.RelativePath()), func(ctx context.Context) error {
41-
_, _, err := runCmdString(ctx, repo, gitcmd.NewCommand("config").
41+
_, err := runCmdString(ctx, repo, gitcmd.NewCommand("config").
4242
AddDynamicArguments(key, value))
4343
return err
4444
})

modules/gitrepo/diff.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func GetDiffShortStatByCmdArgs(ctx context.Context, repo Repository, trustedArgs
2020
// we get:
2121
// " 9902 files changed, 2034198 insertions(+), 298800 deletions(-)\n"
2222
cmd := gitcmd.NewCommand("diff", "--shortstat").AddArguments(trustedArgs...).AddDynamicArguments(dynamicArgs...)
23-
stdout, _, err := runCmdString(ctx, repo, cmd)
23+
stdout, err := runCmdString(ctx, repo, cmd)
2424
if err != nil {
2525
return 0, 0, 0, err
2626
}

modules/gitrepo/remote.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ func GitRemoteAdd(ctx context.Context, repo Repository, remoteName, remoteURL st
3636
return errors.New("unknown remote option: " + string(options[0]))
3737
}
3838
}
39-
_, _, err := runCmdString(ctx, repo, cmd.AddDynamicArguments(remoteName, remoteURL))
39+
_, err := runCmdString(ctx, repo, cmd.AddDynamicArguments(remoteName, remoteURL))
4040
return err
4141
})
4242
}
4343

4444
func GitRemoteRemove(ctx context.Context, repo Repository, remoteName string) error {
4545
return globallock.LockAndDo(ctx, getRepoConfigLockKey(repo.RelativePath()), func(ctx context.Context) error {
4646
cmd := gitcmd.NewCommand("remote", "rm").AddDynamicArguments(remoteName)
47-
_, _, err := runCmdString(ctx, repo, cmd)
47+
_, err := runCmdString(ctx, repo, cmd)
4848
return err
4949
})
5050
}

0 commit comments

Comments
 (0)