-
Notifications
You must be signed in to change notification settings - Fork 64
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
Follow-up to gzip encoding of request body #343
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ae11c18
Add semver to go.mod
mrnugget e704e25
Bring back tests for sourcegraphVersionCheck
mrnugget bf69b81
Extract version check into public function
mrnugget e31483a
Move check for gzip compression to campaigns service
mrnugget 8def51f
Fix unmarshaling of sourcegraph version
mrnugget f41d176
Add CHANGELOG
mrnugget File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package api | ||
|
||
import ( | ||
"regexp" | ||
|
||
"github.com/Masterminds/semver" | ||
) | ||
|
||
func CheckSourcegraphVersion(version, constraint, minDate string) (bool, error) { | ||
if version == "dev" || version == "0.0.0+dev" { | ||
return true, nil | ||
} | ||
|
||
buildDate := regexp.MustCompile(`^\d+_(\d{4}-\d{2}-\d{2})_[a-z0-9]{7}$`) | ||
matches := buildDate.FindStringSubmatch(version) | ||
if len(matches) > 1 { | ||
return matches[1] >= minDate, nil | ||
} | ||
|
||
c, err := semver.NewConstraint(constraint) | ||
if err != nil { | ||
return false, nil | ||
} | ||
|
||
v, err := semver.NewVersion(version) | ||
if err != nil { | ||
return false, err | ||
} | ||
return c.Check(v), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package api | ||
|
||
import "testing" | ||
|
||
func TestCheckSourcegraphVersion(t *testing.T) { | ||
for _, tc := range []struct { | ||
currentVersion, constraint, minDate string | ||
expected bool | ||
}{ | ||
{ | ||
currentVersion: "3.12.6", | ||
constraint: ">= 3.12.6", | ||
minDate: "2020-01-19", | ||
expected: true, | ||
}, | ||
{ | ||
currentVersion: "3.12.6-rc.1", | ||
constraint: ">= 3.12.6-0", | ||
minDate: "2020-01-19", | ||
expected: true, | ||
}, | ||
{ | ||
currentVersion: "3.12.6", | ||
constraint: ">= 3.13", | ||
minDate: "2020-01-19", | ||
expected: false, | ||
}, | ||
{ | ||
currentVersion: "3.13.0", | ||
constraint: ">= 3.13", | ||
minDate: "2020-01-19", | ||
expected: true, | ||
}, | ||
{ | ||
currentVersion: "dev", | ||
constraint: ">= 3.13", | ||
minDate: "2020-01-19", | ||
expected: true, | ||
}, | ||
{ | ||
currentVersion: "0.0.0+dev", | ||
constraint: ">= 3.13", | ||
minDate: "2020-01-19", | ||
expected: true, | ||
}, | ||
{ | ||
currentVersion: "54959_2020-01-29_9258595", | ||
minDate: "2020-01-19", | ||
constraint: ">= 999.13", | ||
expected: true, | ||
}, | ||
{ | ||
currentVersion: "54959_2020-01-29_9258595", | ||
minDate: "2020-01-30", | ||
constraint: ">= 999.13", | ||
expected: false, | ||
}, | ||
{ | ||
currentVersion: "54959_2020-01-29_9258595", | ||
minDate: "2020-01-29", | ||
constraint: ">= 0.0", | ||
expected: true, | ||
}, | ||
} { | ||
actual, err := CheckSourcegraphVersion(tc.currentVersion, tc.constraint, tc.minDate) | ||
if err != nil { | ||
t.Errorf("err: %s", err) | ||
} | ||
|
||
if actual != tc.expected { | ||
t.Errorf("wrong result. want=%t, got=%t (version=%q, constraint=%q)", tc.expected, actual, tc.currentVersion, tc.constraint) | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It looks like
goimports
is what keeps adding theioaux
alias.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.
And I think it's correct, since the package defined in
teereadcloser
is calledioaux
: https://github.com/jig/teereadcloser/blob/953720c48e058a8869b07daa7db756dc7823b2e1/teereadcloser.go#L5