Skip to content

Commit

Permalink
fix(NA): apply feedback from pr review for isCorrectGitVersionInstalled
Browse files Browse the repository at this point in the history
  • Loading branch information
mistic committed Dec 2, 2020
1 parent 9f67612 commit d404ea2
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions packages/kbn-dev-utils/src/precommit_hook/git_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,11 @@ export async function isCorrectGitVersionInstalled() {
})
).stdout.trim();

const gitVersionMatches = rawGitVersionStr.match(/[0-9]+(\.[0-9]+)+/);
const gitVersion =
gitVersionMatches && gitVersionMatches.length > 0 ? gitVersionMatches[0] : false;

if (!gitVersion) {
return false;
}

const correctGitVersionMatches = gitVersion.match(/([0-9]+)\.([0-9]+)/);
if (!correctGitVersionMatches || correctGitVersionMatches.length < 3) {
const match = rawGitVersionStr.match(/[0-9]+(\.[0-9]+)+/);
if (!match) {
return false;
}

const versionMajor = Number(correctGitVersionMatches[1]);
const versionMinor = Number(correctGitVersionMatches[2]);
return versionMajor >= 2 && versionMinor >= 5;
const [major, minor] = match[0].split('.').map((n) => parseInt(n, 10));
return major > 2 || (major === 2 && minor >= 5);
}

0 comments on commit d404ea2

Please sign in to comment.