aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2023-02-21 14:16:25 +0800
committerGitHub <noreply@github.com>2023-02-21 14:16:25 +0800
commitc50d4202ef23b59d25e259f0ec6e18a5e94c1b18 (patch)
treef7d7196e53b3e9d78f2290de47ea4860b70fa8e5
parent660a83bd2ec1be02ca6eea7a84346f6cd1a31fce (diff)
downloadgitea-c50d4202ef23b59d25e259f0ec6e18a5e94c1b18.tar.gz
gitea-c50d4202ef23b59d25e259f0ec6e18a5e94c1b18.zip
Use `--message=%s` for git commit message (#23028) (#23029)
Backport #23028 This backport is done by manually because the git module is different.
-rw-r--r--modules/git/commit.go2
-rw-r--r--modules/repository/init.go2
-rw-r--r--services/pull/merge.go8
3 files changed, 6 insertions, 6 deletions
diff --git a/modules/git/commit.go b/modules/git/commit.go
index 061adc1082..ec2cc8ad81 100644
--- a/modules/git/commit.go
+++ b/modules/git/commit.go
@@ -132,7 +132,7 @@ func CommitChangesWithArgs(repoPath string, args []CmdArg, opts CommitChangesOpt
if opts.Author != nil {
cmd.AddArguments(CmdArg(fmt.Sprintf("--author='%s <%s>'", opts.Author.Name, opts.Author.Email)))
}
- cmd.AddArguments("-m").AddDynamicArguments(opts.Message)
+ cmd.AddArguments(CmdArg("--message=" + opts.Message))
_, _, err := cmd.RunStdString(&RunOpts{Dir: repoPath})
// No stderr but exit status 1 means nothing to commit.
diff --git a/modules/repository/init.go b/modules/repository/init.go
index 65072a9599..c1b97069ff 100644
--- a/modules/repository/init.go
+++ b/modules/repository/init.go
@@ -319,7 +319,7 @@ func initRepoCommit(ctx context.Context, tmpPath string, repo *repo_model.Reposi
cmd := git.NewCommand(ctx,
"commit", git.CmdArg(fmt.Sprintf("--author='%s <%s>'", sig.Name, sig.Email)),
- "-m", "Initial commit",
+ "--message=Initial commit",
)
sign, keyID, signer, _ := asymkey_service.SignInitialCommit(ctx, tmpPath, u)
diff --git a/services/pull/merge.go b/services/pull/merge.go
index 2ae23b3447..3a67919f48 100644
--- a/services/pull/merge.go
+++ b/services/pull/merge.go
@@ -516,7 +516,7 @@ func rawMerge(ctx context.Context, pr *issues_model.PullRequest, doer *user_mode
}
sig := pr.Issue.Poster.NewGitSig()
if signArg == "" {
- if err := git.NewCommand(ctx, "commit", git.CmdArg(fmt.Sprintf("--author='%s <%s>'", sig.Name, sig.Email)), "-m").AddDynamicArguments(message).
+ if err := git.NewCommand(ctx, "commit", git.CmdArg(fmt.Sprintf("--author='%s <%s>'", sig.Name, sig.Email)), git.CmdArg("--message="+message)).
Run(&git.RunOpts{
Env: env,
Dir: tmpBasePath,
@@ -534,7 +534,7 @@ func rawMerge(ctx context.Context, pr *issues_model.PullRequest, doer *user_mode
if err := git.NewCommand(ctx, "commit").
AddArguments(signArg).
AddArguments(git.CmdArg(fmt.Sprintf("--author='%s <%s>'", sig.Name, sig.Email))).
- AddArguments("-m").AddDynamicArguments(message).
+ AddArguments(git.CmdArg("--message=" + message)).
Run(&git.RunOpts{
Env: env,
Dir: tmpBasePath,
@@ -644,7 +644,7 @@ func rawMerge(ctx context.Context, pr *issues_model.PullRequest, doer *user_mode
func commitAndSignNoAuthor(ctx context.Context, pr *issues_model.PullRequest, message string, signArg git.CmdArg, tmpBasePath string, env []string) error {
var outbuf, errbuf strings.Builder
if signArg == "" {
- if err := git.NewCommand(ctx, "commit", "-m").AddDynamicArguments(message).
+ if err := git.NewCommand(ctx, "commit", git.CmdArg("--message="+message)).
Run(&git.RunOpts{
Env: env,
Dir: tmpBasePath,
@@ -655,7 +655,7 @@ func commitAndSignNoAuthor(ctx context.Context, pr *issues_model.PullRequest, me
return fmt.Errorf("git commit [%s:%s -> %s:%s]: %w\n%s\n%s", pr.HeadRepo.FullName(), pr.HeadBranch, pr.BaseRepo.FullName(), pr.BaseBranch, err, outbuf.String(), errbuf.String())
}
} else {
- if err := git.NewCommand(ctx, "commit").AddArguments(signArg).AddArguments("-m").AddDynamicArguments(message).
+ if err := git.NewCommand(ctx, "commit").AddArguments(signArg).AddArguments(git.CmdArg("--message=" + message)).
Run(&git.RunOpts{
Env: env,
Dir: tmpBasePath,