github.com/argoproj/argo-cd@v1.8.7/ui/src/app/shared/components/revision.tsx (about)

     1  import * as React from 'react';
     2  import {revisionUrl} from './urls';
     3  
     4  export const Revision = ({repoUrl, revision, children}: {repoUrl: string; revision: string; children?: React.ReactNode}) => {
     5      revision = revision || '';
     6      const url = revisionUrl(repoUrl, revision);
     7      const content = children || (isSHA(revision) ? revision.substr(0, 7) : revision);
     8      return url !== null ? <a href={url}>{content}</a> : <span>{content}</span>;
     9  };
    10  
    11  export const isSHA = (revision: string) => {
    12      // https://stackoverflow.com/questions/468370/a-regex-to-match-a-sha1
    13      return revision.match(/^[a-f0-9]{5,40}$/) !== null;
    14  };