Use git tag --contains REV for the IDF_Scm::inTags() implementation.
This works similar to git branch --contains REV; additionally give the revision id and not some possibly symbolic name to the inBranches() call when we determine the branches a commit is in.
This commit is contained in:
parent
b75884c57e
commit
6fb9b72e22
@ -52,6 +52,7 @@
|
||||
- Disable browser autocomplete of password fields in the account settings (issue 616)
|
||||
- Improvements in the automatic linker parser (issue 618)
|
||||
- The `createIssue` API method did not check the API authentication (issue 619)
|
||||
- Print active git branch heads and tags in bold
|
||||
|
||||
## Documentation
|
||||
|
||||
|
@ -238,35 +238,29 @@ class IDF_Scm_Git extends IDF_Scm
|
||||
**/
|
||||
public function inTags($commit, $path)
|
||||
{
|
||||
return $this->_inObject($commit, 'tag');
|
||||
if (isset($this->cache['inTags'][$commit])) {
|
||||
return $this->cache['inTags'][$commit];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns in which branches or tags a commit is.
|
||||
*
|
||||
* @param string Commit
|
||||
* @param string Object's type: 'branch' or 'tag'.
|
||||
* @return array
|
||||
*/
|
||||
private function _inObject($commit, $object)
|
||||
{
|
||||
$object = strtolower($object);
|
||||
if ('branch' === $object) {
|
||||
$objects = $this->getBranches();
|
||||
} else if ('tag' === $object) {
|
||||
$objects = $this->getTags();
|
||||
} else {
|
||||
throw new InvalidArgumentException(sprintf(__('Invalid value for the parameter %1$s: %2$s. Use %3$s.'),
|
||||
'$object',
|
||||
$object,
|
||||
'\'branch\' or \'tag\''));
|
||||
$cmd = Pluf::f('idf_exec_cmd_prefix', '')
|
||||
.sprintf('GIT_DIR=%s %s tag --contains %s',
|
||||
escapeshellarg($this->repo),
|
||||
Pluf::f('git_path', 'git'),
|
||||
escapeshellarg($commit));
|
||||
self::exec('IDF_Scm_Git::inTags', $cmd, $out, $return);
|
||||
if (0 != $return) {
|
||||
throw new IDF_Scm_Exception(sprintf($this->error_tpl,
|
||||
$cmd, $return,
|
||||
implode("\n", $out)));
|
||||
}
|
||||
unset($object);
|
||||
$result = array();
|
||||
if (array_key_exists($commit, $objects)) {
|
||||
$result[] = $commit;
|
||||
|
||||
$res = array();
|
||||
foreach ($out as $line) {
|
||||
$res[] = $line;
|
||||
}
|
||||
return $result;
|
||||
|
||||
$this->cache['inTags'][$commit] = $res;
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -527,7 +521,7 @@ class IDF_Scm_Git extends IDF_Scm
|
||||
$out[0]->diff = '';
|
||||
}
|
||||
|
||||
$out[0]->branch = implode(', ', $this->inBranches($commit, null));
|
||||
$out[0]->branch = implode(', ', $this->inBranches($out[0]->commit, null));
|
||||
return $out[0];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user