diff options
author | Benno <blueworrybear@gmail.com> | 2019-10-30 13:58:18 +0800 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2019-10-30 13:58:18 +0800 |
commit | e6706df49ddc4ad7e02901c054b2f344894d7193 (patch) | |
tree | 90aaa1d46a9818c0611c885d65cedf23be9074f8 /routers/repo/compare.go | |
parent | 7bb817e6d19f21ccb16c6ba1eecd0e89fd052322 (diff) | |
download | gitea-e6706df49ddc4ad7e02901c054b2f344894d7193.tar.gz gitea-e6706df49ddc4ad7e02901c054b2f344894d7193.zip |
Create PR on Current Repository by Default (#8670)
* 'update'
* Send push tag event when release created
* send tag create event while release created in UI
* update to go v1.13
* fix gofmt error
* fix #8576 create pull request on current repository by default
Diffstat (limited to 'routers/repo/compare.go')
-rw-r--r-- | routers/repo/compare.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/routers/repo/compare.go b/routers/repo/compare.go index f8534f68b7..b9e14abfb8 100644 --- a/routers/repo/compare.go +++ b/routers/repo/compare.go @@ -339,12 +339,40 @@ func PrepareCompareDiff( return false } +// parseBaseRepoInfo parse base repository if current repo is forked. +// The "base" here means the repository where current repo forks from, +// not the repository fetch from current URL. +func parseBaseRepoInfo(ctx *context.Context, repo *models.Repository) error { + if !repo.IsFork { + return nil + } + if err := repo.GetBaseRepo(); err != nil { + return err + } + if err := repo.BaseRepo.GetOwnerName(); err != nil { + return err + } + baseGitRepo, err := git.OpenRepository(models.RepoPath(repo.BaseRepo.OwnerName, repo.BaseRepo.Name)) + if err != nil { + return err + } + ctx.Data["BaseRepoBranches"], err = baseGitRepo.GetBranches() + if err != nil { + return err + } + return nil +} + // CompareDiff show different from one commit to another commit func CompareDiff(ctx *context.Context) { headUser, headRepo, headGitRepo, compareInfo, baseBranch, headBranch := ParseCompareInfo(ctx) if ctx.Written() { return } + if err := parseBaseRepoInfo(ctx, headRepo); err != nil { + ctx.ServerError("parseBaseRepoInfo", err) + return + } nothingToCompare := PrepareCompareDiff(ctx, headUser, headRepo, headGitRepo, compareInfo, baseBranch, headBranch) if ctx.Written() { |