Skip to content

Validate CommitHash and ShorCommitHash #43

@josecelano

Description

@josecelano

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions