-
-
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
Support shortened commit SHAs in URLs (#6450) #6452
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
Can we support the shortened sha1 but redirect to the full actual one ? |
This supports using a git SHA of any length between 7 and 40 characters in URLs (e.g. /src/commit/SHA/...). Previously only commit SHAs of the full 40 character length were supported. The RepoRefAny ref type is used in one place, in the /api/v1/user/repo/raw API endpoint where it is used to guess whether the remainder of the path is a ref name followed by a file path or merely a file path. There is no good way to guess whether a shortened SHA is intended in that circumstance (e.g., /raw/beefcafe/README.txt could be /README.txt in the beefcafe{..32} commit, or /beefcafe/README.txt on the master branch). For this case, we don't support shortened SHAs and only match on the full one. Signed-off-by: James E. Blair <jeblair@redhat.com>
Codecov Report
@@ Coverage Diff @@
## master #6452 +/- ##
==========================================
+ Coverage 39.39% 39.41% +0.01%
==========================================
Files 393 393
Lines 53271 53277 +6
==========================================
+ Hits 20988 20998 +10
+ Misses 29297 29292 -5
- Partials 2986 2987 +1
Continue to review full report at Codecov.
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 months. Thank you for your contributions. |
@@ -491,8 +491,10 @@ const ( | |||
RepoRefBranch | |||
// RepoRefTag tag | |||
RepoRefTag | |||
// RepoRefCommit commit | |||
// RepoRefCommit short or long commit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't add a value in the middle of the enums.
We don't do that for any other endpoint that allows shortened hashes currently, so if we would want to start doing that, wouldn't it be better for another PR that updates all of them to such behavior? |
as of my understanding still needed for golang/go#39019 ? |
This supports using a git SHA of any length between 7 and 40
characters in URLs (e.g. /src/commit/SHA/...). Previously
only commit SHAs of the full 40 character length were supported.
Signed-off-by: James E. Blair jeblair@redhat.com