/*
github.getDigest

The `newValue` supplied here should be a valid tag for the docker image.

This function will simply return the latest commit hash for the configured repository.
970552
async function getTagCommit(githubRepo, tag) {
  const cachedResult = await renovateCache.get(
    cacheNamespace,
    getCacheKey(githubRepo, `tag-${tag}`)
  );
  // istanbul ignore if
  if (cachedResult) {
    return cachedResult;
  }
  let digest;
  try {
    const url = `https://api.github.com/repos/${githubRepo}/git/refs/tags/${tag}`;
    digest = (await ghGot(url)).body.object.sha;
  } catch (err) {
    logger.info(
      { githubRepo, err },
      'Error getting tag commit from GitHub repo'
    );
  }
  if (!digest) {
    return null;
  }
  const cacheMinutes = 120;
  await renovateCache.set(
    cacheNamespace,
    getCacheKey(githubRepo, `tag-${tag}`),
    digest,
    cacheMinutes
  );
  return digest;
}
870031
def pull(client, revision, auto_login):
    """"""
    registry_url = detect_registry_url(client, auto_login=auto_login)

    repo = client.repo
    sha = repo.rev_parse(revision).hexsha
    short_sha = repo.git.rev_parse(sha, short=7)

    image = '{registry}:{short_sha}'.format(
        registry=registry_url.image, short_sha=short_sha
    )

    result = subprocess.run(['docker', 'image', 'pull', image])
    if result.returncode != 0:
        raise click.ClickException(
            'The image "{image}" was not pulled.\n\n'
            'Push the repository to the server or build the image manually:\n'
            '\n\tdocker build -t {image} .'.format(image=image)
        )
123175
async function getCommitsAfter(commit) {
  if (!args.includes('--no-fetch')) {
    await simpleGit.fetch();
  }
  const log = await simpleGit.log({
    from: commit,
    to: 'origin/master',
    format: logFormat,
    splitter: logSplitter,
  });
  return log.all.reverse();
}
1366752
private String getRunDate(GitHubRepo repo, boolean firstRun, boolean missingCommits) {
        if (missingCommits) {
            long repoOffsetTime = getRepoOffsetTime(repo);
            if (repoOffsetTime > 0) {
                return getDate(new DateTime(getRepoOffsetTime(repo)), 0, settings.getOffsetMinutes()).toString();
            } else {
                return getDate(new DateTime(repo.getLastUpdated()), 0, settings.getOffsetMinutes()).toString();
            }
        }
        if (firstRun) {
            int firstRunDaysHistory = settings.getFirstRunHistoryDays();
            if (firstRunDaysHistory > 0) {
                return getDate(new DateTime(), firstRunDaysHistory, 0).toString();
            } else {
                return getDate(new DateTime(), FIRST_RUN_HISTORY_DEFAULT, 0).toString();
            }
        } else {
            return getDate(new DateTime(repo.getLastUpdated()), 0, settings.getOffsetMinutes()).toString();
        }
    }
924628
function _rawGithubUrl (resolvedPackageRoot) {
  var { packageJson, relativeFile } = resolvedPackageRoot
  const orgRepo = _githubOrgRepo(packageJson && packageJson.repository && packageJson.repository.url)
  if (orgRepo) {
    return `https://raw.githubusercontent.com/${orgRepo}/v${packageJson.version}/${relativeFile}`
  }
}
1064555
def commit_container(self, container_id, image=None, message=None):
        
        logger.info("committing container '%s'", container_id)
        logger.debug("container_id = '%s', image = '%s', message = '%s'",
                     container_id, image, message)
        tag = None
        if image:
            tag = image.tag
            image = image.to_str(tag=False)
        response = self.d.commit(container_id, repository=image, tag=tag, message=message)
        logger.debug("response = '%s'", response)
        try:
            return response['Id']
        except KeyError:
            logger.error("ID missing from commit response")
            raise RuntimeError("ID missing from commit response")
207800
function getDigest(req) {
    // most other servers
    var digest = req.headers["authorization"];
    if (digest && digest.toLowerCase().indexOf("digest") === 0)
        return digest.substr(7);
    else
        return null;
}
1371495
function tag_version(){
	return new Promise((resolve, reject)=>{
		const pkg = reload('../../package.json');
    const tag = `v${pkg.version}`;
    gutil.log('Tagging as: '+gutil.colors.cyan(tag));
    git.tag(tag, `Tagging as ${tag}`, (err)=>{
			checkError(err);
			resolve(tag);
    })
	})
}
512599
function fetchRepoREADME (repo) {
  request({
    uri: 'https://api.github.com/repos/' + repo + '/readme',
    headers: _.extend(headers, {

      // Get raw README content
      'Accept': 'application/vnd.github.VERSION.raw'
    })
  },
  function (error, response, body) {
    if (!error && response.statusCode === 200) {
      lintMarkdown(body, repo);
    } else {
      if (response.headers['x-ratelimit-remaining'] === '0') {
        getAuthToken();
      } else {
        console.log('README for https://github.com/' + repo.blue + ' not found.'.red);
        return;
      }
    }
  });
}
67124
public int getAndIncrement (K key, int defaultValue, int increment) {
		int hashCode = key.hashCode();
		int index = hashCode & mask;
		if (!key.equals(keyTable[index])) {
			index = hash2(hashCode);
			if (!key.equals(keyTable[index])) {
				index = hash3(hashCode);
				if (!key.equals(keyTable[index])) return getAndIncrementStash(key, defaultValue, increment);
			}
		}
		int value = valueTable[index];
		valueTable[index] = value + increment;
		return value;
	}
1005381
function parseTag (tag, repoOwner, imageName, supplyDefaults = true) {
  let sourceTag = tag
  if (!tag && supplyDefaults) {
    sourceTag = 'latest'
  }
  const parts = sourceTag ? sourceTag.split('_') : []
  if (parts.length > 6) {
    // someone has used underscores in their owner/repo/branch name :|
    return parseProblemTag(sourceTag, repoOwner, imageName)
  } else if (parts.length === 0) {
    return [ repoOwner, imageName, undefined, undefined, undefined, undefined ] // allows for upstream filters
  } else if (parts.length === 1) {
    if (sourceTag === 'latest') {
      return [ repoOwner, imageName, 'master', 'latest' ]
    } else {
      return [ repoOwner, imageName, 'master', sourceTag ]
    }
  } else if (parts.length === 2) {
    return [ repoOwner, imageName, 'master', parts[ 0 ], undefined, parts[ 1 ] ]
  } else if (parts.length === 3) {
    return [ repoOwner, imageName, 'master', ...parts ]
  } else if (parts.length === 4) {
    return [ repoOwner, imageName, ...parts ]
  } else if (parts.length === 6) {
    return parts
  }
}
35478
def get_new_version(self, last_version, last_commit,
                        diff_to_increase_ratio):
        

        version = Version(last_version)
        diff = self.get_diff(last_commit, self.get_last_commit_hash())
        total_changed = diff[Diff.ADD] + diff[Diff.DEL]

        version.increase_by_changes(total_changed, diff_to_increase_ratio)
        return version
75857
def get_git_commit(self, sha):
        
        assert isinstance(sha, (str, unicode)), sha
        headers, data = self._requester.requestJsonAndCheck(
            "GET",
            self.url + "/git/commits/" + sha
        )
        return github.GitCommit.GitCommit(self._requester, headers, data, completed=True)
1266174
private RepositoryId getRepository(final String owner, final String name) throws GitHubException {
		RepositoryId repository = null;
		if(StringUtils.isNotBlank(name) && StringUtils.isNotBlank(owner)){
			repository = RepositoryId.create(owner, name);
		}else{
			throw new GitHubException("No GitHub repository (owner and name) configured");
		}
		if (log.isDebugEnabled()){
			log.debug(MessageFormat.format("Using GitHub repository {0}", repository.generateId()));
		}
		return repository;
	}
1216887
function commit() {
		console.log( "Adding files to dist..." );
		Release.exec( "git add -A", "Error adding files." );
		Release.exec(
			"git commit -m \"Release " + Release.newVersion + "\"",
			"Error committing files."
		);
		console.log();

		console.log( "Tagging release on dist..." );
		Release.exec( "git tag " + Release.newVersion,
			"Error tagging " + Release.newVersion + " on dist repo." );
		Release.tagTime = Release.exec( "git log -1 --format=\"%ad\"",
			"Error getting tag timestamp." ).trim();
	}
128048
def push(self, repository=None, tag=None):
        

        image = self

        if repository or tag:
            image = self.tag_image(repository, tag)

        for json_e in self.d.push(repository=image.name, tag=image.tag, stream=True, decode=True):
            logger.debug(json_e)
            status = graceful_get(json_e, "status")
            if status:
                logger.info(status)
            else:
                error = graceful_get(json_e, "error")
                if error is not None:
                    logger.error(status)
                    raise ConuException("There was an error while pushing the image %s: %s",
                                        self.name, error)
        return image
292209
def get_last_version(skip_tags=None) -> Optional[str]:
    

    debug('get_last_version skip_tags=', skip_tags)
    check_repo()
    skip_tags = skip_tags or []

    def version_finder(tag):
        if isinstance(tag.commit, TagObject):
            return tag.tag.tagged_date
        return tag.commit.committed_date

    for i in sorted(repo.tags, reverse=True, key=version_finder):
        if re.match(r'v\d+\.\d+\.\d+', i.name):
            if i.name in skip_tags:
                continue
            return i.name[1:]
    return None