We could validate the commit hash (40 characters):
export class CommitHash {
value: string
constructor(value: string) {
// TODO: validation
this.value = value
}
...
}
And short commit hash (7 character):
export class ShortCommitHash implements Nullable {
private value: string
constructor(value: string) {
// TODO: validation
this.value = value
}
...
}
Sample implementation: https://github.com/kensho-technologies/check-more-types/blob/5356e344fc64f8130ee1f17de293abda695cf015/src/git.js#L35-L39
We wanted to force to use always the 40-character version to avoid ambiguity, but SimpleGit commit returns the short version. We could use our SimpleGit wrapper to change that behaviour and use always long hashes.
We could validate the commit hash (40 characters):
And short commit hash (7 character):
Sample implementation: https://github.com/kensho-technologies/check-more-types/blob/5356e344fc64f8130ee1f17de293abda695cf015/src/git.js#L35-L39
We wanted to force to use always the 40-character version to avoid ambiguity, but SimpleGit commit returns the short version. We could use our SimpleGit wrapper to change that behaviour and use always long hashes.