-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Compare branches, commits and tags with each other #6991
Compare branches, commits and tags with each other #6991
Conversation
Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>
Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>
…ith eachother Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>
Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>
Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>
…e_tags # Conflicts: # public/css/index.css # routers/repo/pull.go
Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>
Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>
Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>
Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>
Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>
Codecov Report
@@ Coverage Diff @@
## master #6991 +/- ##
==========================================
+ Coverage 41.58% 41.64% +0.05%
==========================================
Files 446 447 +1
Lines 60873 60888 +15
==========================================
+ Hits 25317 25358 +41
+ Misses 32271 32243 -28
- Partials 3285 3287 +2
Continue to review full report at Codecov.
|
Co-Authored-By: zeripath <art27@cantab.net>
I'm not a fan of polluting the main repository and sticking objects within its object database. (Although this is not your fault.) I think we should be either, creating a new temporary repository with references to the head branches and then pulling the changes there, or setting: Lines 18 to 19 in cf857fa
appropriately as per: Lines 64 to 68 in cf857fa
And fetch into a non-reffed branch. Now this doesn't have to be done in this PR, but we should do it. |
…e_tags # Conflicts: # templates/repo/diff/page.tmpl
Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>
…nto feature/4567-Compare_tags
We should create a new issue for that. :) |
Can we compare commits with their 9 character hash that we usually see in lists of commits? I can't do this: http://localhost:3000/root/test/compare/3c5db14a4...d2f998efb but can do this: http://localhost:3000/root/test/compare/3c5db140a4f6778cd4a50217fafd3a0a0d3d6481...d42f998efbe325b5d4431ec1e56d227a94cb777a. On Github I can do it with the short hash that they show While we show 9 characters of the commit SHA and GitHub shows only 7, Gitea commit URL allows for 7, so would be great if compare also took 7 or more characters to find the commit SHA to compare. |
No, we can't. Gitea uses go-git to interact with Git repositories. As I explained in #4567, go-git does not support short hashes at the moment. |
@saitho Ah, thanks for that explanation. Didn't know. |
@saitho Moving our conversation from the issue to here. I know from https://github.com/go-gitea/gitea/blob/master/routers/repo/commit.go#L200 that this is what figures out the commit ID for a short hash or a branch name if the string isn't 40 characters long. Uses rev-parse of the git command, such as |
Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>
Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>
Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>
We should do that here, because the temporary branch I created when head repository is a fork shows up in the branch list. Even if we deleted it afterwards a user might still be able to check it out. ^^ EDIT: At least I was left with a temporary branch still being visible in Gitea... |
Might have been a leftover from development. Removed it once and it didn't come back when I tested the compare functionality. |
* Supports tags when comparing commits or branches Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Hide headline when only comparing and don't load unused data Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Merges compare logics to allow comparing branches, commits and tags with eachother Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Display branch or tag instead of commit when used for comparing Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Show pull request form after click on button Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Transfers relevant pull.go changes from master to compare.go Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Fixes error when comparing forks against a commit or tag Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Removes console.log from JavaScript file Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Show icon next to commit reference when comparing branch or tag Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Updates css file Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Fixes import order * Renames template variable * Update routers/repo/compare.go Co-Authored-By: zeripath <art27@cantab.net> * Update from master Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Allow short-shas in compare * Renames prInfo to compareInfo Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Check PR permissions only if compare is pull request Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Adjusts comment Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Use compareInfo instead of prInfo
Resolves #4567
Currently the comparing branches and commits is two separate routes and the logic is spread on multiple files. This pull request puts that logic in one place and allows comparing commits, branches and tags among each other (e.g. compare a branch with a commit, compare a tag with a branch, etc).
When comparing two branches there will be a button "Create pull request" (similarly to GitHub) which will show the pull request form.
Screenshots
Comparing branches (=> Pull Request)
Comparing commit and tag
Comparing tag and branch