Skip to content
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

Added short-hash support to downloads #228

Merged
merged 1 commit into from
Nov 24, 2016

Conversation

Bwko
Copy link
Member

@Bwko Bwko commented Nov 23, 2016

Fixes #211

@codecov-io
Copy link

codecov-io commented Nov 23, 2016

Current coverage is 3.03% (diff: 100%)

Merging #228 into master will not change coverage

@@            master      #228   diff @@
========================================
  Files           33        33          
  Lines         8106      8106          
  Methods          0         0          
  Messages         0         0          
  Branches         0         0          
========================================
  Hits           246       246          
  Misses        7840      7840          
  Partials        20        20          

Powered by Codecov. Last update 2ccdcda...ff0d1bd

@tboerger tboerger added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Nov 23, 2016
@strk
Copy link
Member

strk commented Nov 23, 2016

LGTM - this should go in 1.0.0 as bugfix

@tboerger tboerger added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Nov 23, 2016
@@ -311,7 +311,7 @@ func Download(ctx *context.Context) {
ctx.Handle(500, "GetTagCommit", err)
return
}
} else if len(refName) == 40 {
} else if len(refName) > 7 && len(refName) <= 40 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw, should that be >= 7 instead ?

@strk
Copy link
Member

strk commented Nov 23, 2016

Adding an automated testcase would be great too

@@ -311,7 +311,7 @@ func Download(ctx *context.Context) {
ctx.Handle(500, "GetTagCommit", err)
return
}
} else if len(refName) == 40 {
} else if len(refName) > 7 && len(refName) <= 40 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be == 7 or == 40, beside that I'm not sure if this is the only place that needs to be changed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope, should be 7 <= len(refName) <= 40 just like it is, otherwise f00badf00d.tar.gz wouldn't work 🙂

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So how have it worked before with == 40?

@tboerger tboerger added the type/enhancement An improvement of existing functionality label Nov 23, 2016
@tboerger tboerger added this to the 1.0.0 milestone Nov 23, 2016
@Bwko
Copy link
Member Author

Bwko commented Nov 23, 2016

Currently only a short hash of 8 characters work. But it's not mandatory for a short hash to be x characters long. See http://stackoverflow.com/a/21015031
Maybe we could set it from >=4 (minimum short hash is 4 characters) to <= 40?

@tboerger tboerger added the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label Nov 23, 2016
@ghost
Copy link

ghost commented Nov 23, 2016

LGTM

@tboerger tboerger added the lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. label Nov 23, 2016
@bkcsoft bkcsoft removed the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label Nov 23, 2016
@strk
Copy link
Member

strk commented Nov 24, 2016 via email

@tboerger tboerger added the lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. label Nov 24, 2016
@Bwko
Copy link
Member Author

Bwko commented Nov 24, 2016

That's why I suggested this:

Maybe we could set it from >=4 (minimum short hash is 4 characters) to <= 40?

Question: what happens if a colliding short hash is used ?

Git will produce an ambiguous error:

error: short SHA1 0001 is ambiguous.

@strk
Copy link
Member

strk commented Nov 24, 2016 via email

@thibaultmeyer
Copy link
Contributor

thibaultmeyer commented Nov 24, 2016

Github allow usage of 7 length commit hashes. No collision encountered on big repo (eg: Linux kernel have 700k commits).

By default, GITEA use 10 length short hash on all pages. Maybe we can change routes to accept at least 10 length hash

@Bwko
Copy link
Member Author

Bwko commented Nov 24, 2016

I think it'll throw a 404 error. When using 7 characters the change of a collision is 1 in 250 million

@strk
Copy link
Member

strk commented Nov 24, 2016 via email

@Bwko Bwko force-pushed the feature/short-hash-download branch from f05c051 to 69db193 Compare November 24, 2016 10:35
@Bwko Bwko force-pushed the feature/short-hash-download branch from 69db193 to ff0d1bd Compare November 24, 2016 10:46
@Bwko
Copy link
Member Author

Bwko commented Nov 24, 2016

@strk I've lowered the minimum length to 4. I've just tested this and collisions result in a 404 error

@tboerger
Copy link
Member

LGTM

@strk
Copy link
Member

strk commented Nov 24, 2016

LGTM, please merge @go-gitea/owners

@tboerger tboerger merged commit b6b616b into go-gitea:master Nov 24, 2016
@Bwko Bwko deleted the feature/short-hash-download branch December 27, 2016 16:58
@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing support for short-hash archives download
6 participants