-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Ambiguous compare URL results in 404 #14921
Comments
the simple issue is that the shortcut url: https://try.gitea.io/our-org/custom-project/compare/main...company-org:payed-feature is looking for the payed-feature branch in company-org/project not company-org/custom-project. How would gitea know that you meant company-org/custom-project? |
This is what I thought, but gitea should now that I need a PR from For me it seems that the syntax which is used in the compare URL/view is ambiguous: ORG:BRANCH is not enough to identify a branch in my situation. The current syntax works well when the forked-from repo is owned by another organization with the assumption that it has the same name. With my structure I am hitting the limit to have just one fork of a repo in the same organization, this is why I needed step 3,4 to move the repo. But I think this could be work around by first checking for ambiguity and in case use the full syntax: ORG/REPO:BRANCH. This is actually done in case I select some branch from But somehow not all branches are shown. The while it should be there: |
So the simplifying code is getting things wrong in this case. The trouble is I can't remember where I put it. |
OK there is no way we can ever use the simplified url in this case - however, that seems like an overkill in the general case - because most people will not be doing this kind of naughty behaviour... Aha. The trick is if the baserepo is a fork then that is the only way you could need the full repo id. diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl
index 4d8d28921..b77f28f92 100644
--- a/templates/repo/home.tmpl
+++ b/templates/repo/home.tmpl
@@ -64,7 +64,7 @@
{{if eq $n 0}}
{{if and .CanCompareOrPull .IsViewBranch (not .Repository.IsArchived)}}
<div class="fitted item mx-0">
- <a href="{{.BaseRepo.Link}}/compare/{{.BaseRepo.DefaultBranch | EscapePound}}...{{if ne .Repository.Owner.Name .BaseRepo.Owner.Name}}{{.Repository.Owner.Name}}:{{end}}{{.BranchName | EscapePound}}">
+ <a href="{{.BaseRepo.Link}}/compare/{{.BaseRepo.DefaultBranch | EscapePound}}...{{if ne .Repository.Owner.Name .BaseRepo.Owner.Name}}{{.Repository.Owner.Name}}{{if .BaseRepo.IsFork}}/{{.Repository.Name}}{{end}}:{{end}}{{.BranchName | EscapePound}}">
<button id="new-pull-request" class="ui compact basic button">{{if .PullRequestCtx.Allowed}}{{.i18n.Tr "repo.pulls.compare_changes"}}{{else}}{{.i18n.Tr "action.compare_branch"}}{{end}}</button>
</a>
</div>
sorts out the initial 404 |
This should make 1.14 but likely rc2 |
Thanks @zeripath for your fast reaction and patch. Since I was always using the docker container you provided, I would have to build it on my own and push it to our server. Easier would be some kind of nightly build to test this out. Is there something similar with your provided patch? |
the associated PR touches two templates only and which can be placed in your custom folder as per https://docs.gitea.io/en-us/customizing-gitea/ |
I've tryied it out, but it requires other templates in the $GITEA_CUSTOM path, an error message said. So I aborted testing. |
But since you are releasing so frequently, I guess I don't have to wait so long for this to get released. |
This won't be merged until v1.14.0 (or a release candidate) is released. You can get the template files from: https://github.com/CL-Jeremy/gitea/tree/backport-fix-14921/templates/repo. Download these two raw files: home.tmpl and diff/compare.tmpl, put them in These files are generated with:
|
[x]
):Description
There is a specific structure of repositories and organizations we need in order to complete our work. First I'll explain our use case. In Steps to reproduce I'll show how I could create the organization/repository structure, exactly how I was expecting it to be. However when trying to create a specific PR the feature-branch is not listed, shown in Steps to show that feature branch is not listed. Finally Steps to show 404 and how to adapt compare URL shows how I got the 404 page and how I adapted the compare URL to get the desired PR.
The repository structure is available at https://try.gitea.io. If you'd like me to create this structure somewhere else, just tell me.
Use case
we
mirror the company's repo to our gitea server insidecompany-org
organizationwe
fork their repository andwe
push to our customizationwe/custom-project
repowe
create PR from the mirror of the company's public repocompany-org/project
to our customizationour-org/custom-project
to merge upstream changeswe
pay the company to develop custom features based on our customized code and thus the company gets access to theircompany-org
organizationcompany
pushes to a forkcompany-org/custom-project
of our customized repowe
create PR from company's custom repocompany-org/custom-project
to our customizationour-org/custom-project
At the end we would like to have the following fork chain:
company-org/project
(mirror) <-our-org/custom-project
<-company-org/custom-project
Steps to reproduce
company/project
company/project
toour-org/custom-project
our-org/custom-project
tothis-is-me/custom-project
[1]this-is-me/custom-project
tocompany-org
[1]payed_feature
tocompany-org/custom-project
repocompany-org/custom-project
Steps to show that feature branch is not listed
7a. Select
main
branch8a. Click
Create Pull Request
9a. Open
pull from
dropdown10a.
payed-feature
is not listedSteps to show 404 and how to adapt compare URL
7b. Select
payed-feature
branch8b. Click
Create Pull Request
-> 4049b. Change compare URL from https://try.gitea.io/our-org/custom-project/compare/main...company-org:payed-feature to https://try.gitea.io/our-org/custom-project/compare/main...company-org/custom-project:payed-feature -> Compare is correctly shown
[1] Steps 3. and 4. were required in order to create a fork in the same organization in which the mirror is located. Creating
the fork directly was not possible since the owner was not listed when forking.
Thoughts and questions
Is this 404 occurring because we have the mirror and a fork of same repository inside one organization? Why is the adapted compare URL working. IMHO this is a popular use case (despite the fact that no one reported this before) or is there another way to accomplish what I want?
The text was updated successfully, but these errors were encountered: