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

git versioning: add method to check if git is available #29

Merged
merged 2 commits into from
Nov 5, 2018

Conversation

coolya
Copy link
Contributor

@coolya coolya commented Oct 22, 2018

Added a helper method to check if git is available so that build scripts can handle this case gracefully instead of catching the exceptions thrown form the underlying API.

@joao-silveira
Copy link
Contributor

Why do you check specifically against git major version 2?

@coolya
Copy link
Contributor Author

coolya commented Oct 23, 2018

git rev-list behaves different in git 1.x. It's pretty unlikely that we will every encounter such ancient git versions but still wanted to make sure.

static boolean isGitVersioningAvailable() {
try {
String output = getCommandOutput("git --version")
return output.contains("2.")
Copy link
Member

Choose a reason for hiding this comment

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

git 3.2.0 will match this :) How about output.startsWith("git version 2")?

As discussed in code review we shoul look for a string starting with
"git version 2" instead of looking for just `contains("2")`.
@coolya
Copy link
Contributor Author

coolya commented Nov 4, 2018

I double checked with the windows version of git and startsWith("git version 2") should be fine.

@coolya coolya merged commit 03fbeda into master Nov 5, 2018
@coolya coolya deleted the check-git-available branch November 5, 2018 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants