mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-15 12:53:53 +02:00
Fix bug
This commit is contained in:
parent
7228fb1498
commit
b4df643ad1
@ -186,6 +186,7 @@ func Clone(ctx context.Context, from, to string, opts CloneRepoOptions) error {
|
|||||||
// PushOptions options when push to remote
|
// PushOptions options when push to remote
|
||||||
type PushOptions struct {
|
type PushOptions struct {
|
||||||
Remote string
|
Remote string
|
||||||
|
LocalBranch string
|
||||||
Branch string
|
Branch string
|
||||||
Force bool
|
Force bool
|
||||||
ForceWithLease string
|
ForceWithLease string
|
||||||
@ -207,7 +208,13 @@ func Push(ctx context.Context, repoPath string, opts PushOptions) error {
|
|||||||
}
|
}
|
||||||
remoteBranchArgs := []string{opts.Remote}
|
remoteBranchArgs := []string{opts.Remote}
|
||||||
if len(opts.Branch) > 0 {
|
if len(opts.Branch) > 0 {
|
||||||
remoteBranchArgs = append(remoteBranchArgs, opts.Branch)
|
var refspec string
|
||||||
|
if opts.LocalBranch != "" {
|
||||||
|
refspec = fmt.Sprintf("%s:%s", opts.LocalBranch, opts.Branch)
|
||||||
|
} else {
|
||||||
|
refspec = opts.Branch
|
||||||
|
}
|
||||||
|
remoteBranchArgs = append(remoteBranchArgs, refspec)
|
||||||
}
|
}
|
||||||
cmd.AddDashesAndList(remoteBranchArgs...)
|
cmd.AddDashesAndList(remoteBranchArgs...)
|
||||||
|
|
||||||
|
|||||||
@ -74,6 +74,7 @@ func initRepoCommit(ctx context.Context, tmpPath string, repo *repo_model.Reposi
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := gitrepo.PushFromLocal(ctx, tmpPath, repo, git.PushOptions{
|
if err := gitrepo.PushFromLocal(ctx, tmpPath, repo, git.PushOptions{
|
||||||
|
LocalBranch: "HEAD",
|
||||||
Branch: defaultBranch,
|
Branch: defaultBranch,
|
||||||
Env: repo_module.InternalPushingEnvironment(u, repo),
|
Env: repo_module.InternalPushingEnvironment(u, repo),
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user