INNER CODE UNIT · TypeScript

GIT_RANGE

modem-dev/hunk · packages/hunk-git/src/index.ts:65

const GIT_RANGE = /^(.*?)(\.\.\.?)(.*)$/;

/** Shorten one complete Git object ID while preserving every named revision spelling. */
function shortenGitObjectId(revision: string) {
  return FULL_GIT_OBJECT_ID.test(revision)
    ? revision.slice(0, GIT_SHORT_OBJECT_ID_LENGTH)
    : revision;
}

/** Shorten full Git object IDs in a display range while preserving named revisions. */
export function describeGitDiffTitleRange(input: {
  readonly range?: string;
  readonly rangeEndpoints?: { readonly from: string; readonly to: string };
}) {
  if (input.rangeEndpoints) {
    return `${shortenGitObjectId(input.rangeEndpoints.from)}..${shortenGitObjectId(input.rangeEndpoints.to)}`;
  }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…