-
Notifications
You must be signed in to change notification settings - Fork 1.4k
throw error if git version is less than 2 #201
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
Conversation
@@ -38,6 +39,8 @@ extension Error: CustomStringConvertible { | |||
return "No version tag found in (\(package)) package. Add a version tag with \"git tag\" command. Example: \"git tag 0.1.0\"" | |||
case NoManifest(let clonePath, let version): | |||
return "The package at `\(clonePath)' has no Package.swift for the specific version: \(version)" | |||
case ObsoleteGitVersion: | |||
return "Git 2.0 or higer is required. Please update git and retry." |
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.
Spelling mistake: higer -> higher
8eab071
to
2298e43
Compare
var version = self.version | ||
if version.hasPrefix(prefix) { | ||
let prefixRange = version.startIndex...version.startIndex.advanced(by: prefix.characters.count) | ||
version.removeSubrange(prefixRange) |
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.
Can just do version = version[version.startIndex.advance(by: prefix.characters.count)..<version.endIndex]
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.
String is not a sequence, so I can't :(
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.
I can do this, but in that case there are to many expressions in 1 line, I think
version = String(version.characters[version.characters.startIndex.advanced(by: prefix.characters.count)..<version.characters.endIndex])
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.
yeah that'll be worse 😅
Specifically what I wanted here was only to check the git version in the event of another git error being thrown, checking every time is wasteful. |
Got it 👍. Is there a convenient way to downgrade git? |
Homebrew can be coaxed into installing old versions. |
All calls to git When the Git error occurs and we catch it. We can:
I think I prefer solution nr.1 We should handle error in place and take necessary actions. System can't work without git, so we should terminate it. Do you agree or have any other solutions proposal ? |
Yes, seems like the right choice. Unless properties become capable of throwing at some point. |
@swift-ci Please test |
Tests are passing. Any more feedback on this one. If no, then I'm going to merge it |
throw error if git version is less than 2
Next time please squash commits like "revert necessary changes" away first. |
I'm sorry. I will do that next time |
np, every project has its unwritten rules. |
[Ninja] Shell-quote $in and $out
Fix https://bugs.swift.org/browse/SR-966.
Require git with version >= 2