lib/git/ensure-tag.js
function ensureTag(cwd, tag) {
  if (tag === 'v0.0.0') {
    // There is no such thing (most likely)
    return null;
  }

  const tagFile = path.join(cwd, '.git', 'refs', 'tags', tag);
  try {
    return fs.readFileSync(tagFile);
  } catch (error) {
    if (error.code !== 'ENOENT') {
      throw error;
    }
    return fetchTag(cwd, tag);
  }
}
function ensureTag(cwd, tag) {
  if (tag === 'v0.0.0') {
    // There is no such thing (most likely)
    return null;
  }

  const tagFile = path.join(cwd, '.git', 'refs', 'tags', tag);
  try {
    return fs.readFileSync(tagFile);
  } catch (error) {
    if (error.code !== 'ENOENT') {
      throw error;
    }
    return fetchTag(cwd, tag);
  }
}
function ensureTag ( cwd , tag ) { if ( tag === 'v0.0.0' ) { // There is no such thing (most likely) return null ; } const tagFile = path . join ( cwd , '.git' , 'refs' , 'tags' , tag ) ; try { return fs . readFileSync ( tagFile ) ; } catch ( error ) { if ( error . code !== 'ENOENT' ) { throw error ; } return fetchTag ( cwd , tag ) ; } }
Ensure that a tag was fetched from the remote

DotCI only fetches the ref that is currently being built.
We need the last version tag to determine the changes.
This checks if a tag exists locally. If it doesn't, it will
fetch the tag from `origin`.
Ensure that a tag was fetched from the remote