Skip to content

Stop cloning unnecessarily on PR update #12839

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove unnecessary delete
Signed-off-by: Andrew Thornton <[email protected]>
  • Loading branch information
zeripath committed Sep 14, 2020
commit 47c1dcbae4c8c215736ec93b77a40de49edf6385
11 changes: 1 addition & 10 deletions services/pull/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"context"
"encoding/json"
"fmt"
"path/filepath"
"strings"
"time"

Expand All @@ -20,7 +19,6 @@ import (
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/notification"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/util"
issue_service "code.gitea.io/gitea/services/issue"

"github.com/unknwon/com"
Expand Down Expand Up @@ -402,16 +400,9 @@ func PushToBaseRepo(pr *models.PullRequest) (err error) {
return fmt.Errorf("unable to load poster %d for pr %d: %v", pr.Issue.PosterID, pr.ID, err)
}

headFile := pr.GetGitRefName()

// Remove head in case there is a conflict.
file := filepath.Join(pr.BaseRepo.RepoPath(), headFile)

_ = util.Remove(file)

if err := git.Push(headRepoPath, git.PushOptions{
Remote: baseRepoPath,
Branch: pr.HeadBranch + ":" + headFile,
Branch: pr.HeadBranch + ":" + pr.GetGitRefName(),
Force: true,
// Use InternalPushingEnvironment here because we know that pre-receive and post-receive do not run on a refs/pulls/...
Env: models.InternalPushingEnvironment(pr.Issue.Poster, pr.BaseRepo),
Expand Down