repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
matteosister/GitElephant | src/GitElephant/Repository.php | Repository.removeGlobalCommandArgument | public function removeGlobalCommandArgument($value)
{
if (in_array($value, $this->globalCommandArguments, true)) {
$index = array_search($value, $this->globalCommandArguments);
unset($this->globalCommandArguments[$index]);
}
} | php | public function removeGlobalCommandArgument($value)
{
if (in_array($value, $this->globalCommandArguments, true)) {
$index = array_search($value, $this->globalCommandArguments);
unset($this->globalCommandArguments[$index]);
}
} | [
"public",
"function",
"removeGlobalCommandArgument",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"globalCommandArguments",
",",
"true",
")",
")",
"{",
"$",
"index",
"=",
"array_search",
"(",
"$",
"value",
... | remove an element form the global command argument list, identified by
value
@param string $value The command argument | [
"remove",
"an",
"element",
"form",
"the",
"global",
"command",
"argument",
"list",
"identified",
"by",
"value"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Repository.php#L1285-L1291 |
matteosister/GitElephant | src/GitElephant/Repository.php | Repository.stash | public function stash(string $message = null, bool $includeUntracked = false, bool $keepIndex = false)
{
$stashCommand = StashCommand::getInstance($this);
$command = $stashCommand->save($message, $includeUntracked, $keepIndex);
$this->caller->execute($command);
} | php | public function stash(string $message = null, bool $includeUntracked = false, bool $keepIndex = false)
{
$stashCommand = StashCommand::getInstance($this);
$command = $stashCommand->save($message, $includeUntracked, $keepIndex);
$this->caller->execute($command);
} | [
"public",
"function",
"stash",
"(",
"string",
"$",
"message",
"=",
"null",
",",
"bool",
"$",
"includeUntracked",
"=",
"false",
",",
"bool",
"$",
"keepIndex",
"=",
"false",
")",
"{",
"$",
"stashCommand",
"=",
"StashCommand",
"::",
"getInstance",
"(",
"$",
... | Save your local modifications to a new stash, and run git reset --hard to revert them.
@param string|null $message
@param boolean $includeUntracked
@param boolean $keepIndex | [
"Save",
"your",
"local",
"modifications",
"to",
"a",
"new",
"stash",
"and",
"run",
"git",
"reset",
"--",
"hard",
"to",
"revert",
"them",
"."
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Repository.php#L1300-L1305 |
matteosister/GitElephant | src/GitElephant/Repository.php | Repository.stashList | public function stashList(array $options = null)
{
$stashCommand = StashCommand::getInstance($this);
$command = $stashCommand->listStashes($options);
$this->caller->execute($command);
return array_map('trim', $this->caller->getOutputLines(true));
} | php | public function stashList(array $options = null)
{
$stashCommand = StashCommand::getInstance($this);
$command = $stashCommand->listStashes($options);
$this->caller->execute($command);
return array_map('trim', $this->caller->getOutputLines(true));
} | [
"public",
"function",
"stashList",
"(",
"array",
"$",
"options",
"=",
"null",
")",
"{",
"$",
"stashCommand",
"=",
"StashCommand",
"::",
"getInstance",
"(",
"$",
"this",
")",
";",
"$",
"command",
"=",
"$",
"stashCommand",
"->",
"listStashes",
"(",
"$",
"o... | Shows stash list
@param array|null $options
@return array | [
"Shows",
"stash",
"list"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Repository.php#L1314-L1321 |
matteosister/GitElephant | src/GitElephant/Repository.php | Repository.stashShow | public function stashShow(string $stash)
{
$stashCommand = StashCommand::getInstance($this);
$command = $stashCommand->show($stash);
$this->caller->execute($command);
return $this->caller->getOutput();
} | php | public function stashShow(string $stash)
{
$stashCommand = StashCommand::getInstance($this);
$command = $stashCommand->show($stash);
$this->caller->execute($command);
return $this->caller->getOutput();
} | [
"public",
"function",
"stashShow",
"(",
"string",
"$",
"stash",
")",
"{",
"$",
"stashCommand",
"=",
"StashCommand",
"::",
"getInstance",
"(",
"$",
"this",
")",
";",
"$",
"command",
"=",
"$",
"stashCommand",
"->",
"show",
"(",
"$",
"stash",
")",
";",
"$... | Shows details for a stash
@param string $stash
@return string | [
"Shows",
"details",
"for",
"a",
"stash"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Repository.php#L1330-L1337 |
matteosister/GitElephant | src/GitElephant/Repository.php | Repository.stashDrop | public function stashDrop(string $stash)
{
$stashCommand = StashCommand::getInstance($this);
$command = $stashCommand->drop($stash);
$this->caller->execute($command);
} | php | public function stashDrop(string $stash)
{
$stashCommand = StashCommand::getInstance($this);
$command = $stashCommand->drop($stash);
$this->caller->execute($command);
} | [
"public",
"function",
"stashDrop",
"(",
"string",
"$",
"stash",
")",
"{",
"$",
"stashCommand",
"=",
"StashCommand",
"::",
"getInstance",
"(",
"$",
"this",
")",
";",
"$",
"command",
"=",
"$",
"stashCommand",
"->",
"drop",
"(",
"$",
"stash",
")",
";",
"$... | Drops a stash
@param string $stash | [
"Drops",
"a",
"stash"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Repository.php#L1344-L1349 |
matteosister/GitElephant | src/GitElephant/Repository.php | Repository.stashApply | public function stashApply(string $stash, bool $index = false)
{
$stashCommand = StashCommand::getInstance($this);
$command = $stashCommand->apply($stash, $index);
$this->caller->execute($command);
} | php | public function stashApply(string $stash, bool $index = false)
{
$stashCommand = StashCommand::getInstance($this);
$command = $stashCommand->apply($stash, $index);
$this->caller->execute($command);
} | [
"public",
"function",
"stashApply",
"(",
"string",
"$",
"stash",
",",
"bool",
"$",
"index",
"=",
"false",
")",
"{",
"$",
"stashCommand",
"=",
"StashCommand",
"::",
"getInstance",
"(",
"$",
"this",
")",
";",
"$",
"command",
"=",
"$",
"stashCommand",
"->",... | Applies a stash
@param string $stash
@param boolean $index | [
"Applies",
"a",
"stash"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Repository.php#L1357-L1362 |
matteosister/GitElephant | src/GitElephant/Repository.php | Repository.stashPop | public function stashPop(string $stash, bool $index = false)
{
$stashCommand = StashCommand::getInstance($this);
$command = $stashCommand->pop($stash, $index);
$this->caller->execute($command);
} | php | public function stashPop(string $stash, bool $index = false)
{
$stashCommand = StashCommand::getInstance($this);
$command = $stashCommand->pop($stash, $index);
$this->caller->execute($command);
} | [
"public",
"function",
"stashPop",
"(",
"string",
"$",
"stash",
",",
"bool",
"$",
"index",
"=",
"false",
")",
"{",
"$",
"stashCommand",
"=",
"StashCommand",
"::",
"getInstance",
"(",
"$",
"this",
")",
";",
"$",
"command",
"=",
"$",
"stashCommand",
"->",
... | Applies a stash, then removes it from the stash
@param string $stash
@param boolean $index | [
"Applies",
"a",
"stash",
"then",
"removes",
"it",
"from",
"the",
"stash"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Repository.php#L1370-L1375 |
matteosister/GitElephant | src/GitElephant/Repository.php | Repository.stashBranch | public function stashBranch(string $branch, string $stash)
{
$stashCommand = StashCommand::getInstance($this);
$command = $stashCommand->branch($branch, $stash);
$this->caller->execute($command);
} | php | public function stashBranch(string $branch, string $stash)
{
$stashCommand = StashCommand::getInstance($this);
$command = $stashCommand->branch($branch, $stash);
$this->caller->execute($command);
} | [
"public",
"function",
"stashBranch",
"(",
"string",
"$",
"branch",
",",
"string",
"$",
"stash",
")",
"{",
"$",
"stashCommand",
"=",
"StashCommand",
"::",
"getInstance",
"(",
"$",
"this",
")",
";",
"$",
"command",
"=",
"$",
"stashCommand",
"->",
"branch",
... | Creates and checks out a new branch named <branchname> starting from the commit at which the <stash> was originally created
@param string $branch
@param string $stash | [
"Creates",
"and",
"checks",
"out",
"a",
"new",
"branch",
"named",
"<branchname",
">",
"starting",
"from",
"the",
"commit",
"at",
"which",
"the",
"<stash",
">",
"was",
"originally",
"created"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Repository.php#L1383-L1388 |
matteosister/GitElephant | src/GitElephant/Repository.php | Repository.stashClear | public function stashClear()
{
$stashCommand = StashCommand::getInstance($this);
$command = $stashCommand->clear();
$this->caller->execute($command);
} | php | public function stashClear()
{
$stashCommand = StashCommand::getInstance($this);
$command = $stashCommand->clear();
$this->caller->execute($command);
} | [
"public",
"function",
"stashClear",
"(",
")",
"{",
"$",
"stashCommand",
"=",
"StashCommand",
"::",
"getInstance",
"(",
"$",
"this",
")",
";",
"$",
"command",
"=",
"$",
"stashCommand",
"->",
"clear",
"(",
")",
";",
"$",
"this",
"->",
"caller",
"->",
"ex... | Save your local modifications to a new stash, and run git reset --hard to revert them. | [
"Save",
"your",
"local",
"modifications",
"to",
"a",
"new",
"stash",
"and",
"run",
"git",
"reset",
"--",
"hard",
"to",
"revert",
"them",
"."
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Repository.php#L1394-L1399 |
matteosister/GitElephant | src/GitElephant/Repository.php | Repository.stashCreate | public function stashCreate()
{
$stashCommand = StashCommand::getInstance($this);
$command = $stashCommand->clear();
$this->caller->execute($command);
return $this->caller->getOutput();
} | php | public function stashCreate()
{
$stashCommand = StashCommand::getInstance($this);
$command = $stashCommand->clear();
$this->caller->execute($command);
return $this->caller->getOutput();
} | [
"public",
"function",
"stashCreate",
"(",
")",
"{",
"$",
"stashCommand",
"=",
"StashCommand",
"::",
"getInstance",
"(",
"$",
"this",
")",
";",
"$",
"command",
"=",
"$",
"stashCommand",
"->",
"clear",
"(",
")",
";",
"$",
"this",
"->",
"caller",
"->",
"e... | Create a stash (which is a regular commit object) and return its object name, without storing it anywhere in the
ref namespace.
@return string | [
"Create",
"a",
"stash",
"(",
"which",
"is",
"a",
"regular",
"commit",
"object",
")",
"and",
"return",
"its",
"object",
"name",
"without",
"storing",
"it",
"anywhere",
"in",
"the",
"ref",
"namespace",
"."
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Repository.php#L1407-L1414 |
matteosister/GitElephant | src/GitElephant/Objects/Diff/DiffChunk.php | DiffChunk.parseLines | private function parseLines(array $lines)
{
$originUnchanged = $this->originStartLine;
$destUnchanged = $this->destStartLine;
$deleted = $this->originStartLine;
$new = $this->destStartLine;
foreach ($lines as $line) {
if (preg_match('/^\+(.*)/', $line)) {
$this->lines[] = new DiffChunkLineAdded($new++, preg_replace('/\+(.*)/', ' $1', $line));
$destUnchanged++;
} else if (preg_match('/^-(.*)/', $line)) {
$this->lines[] = new DiffChunkLineDeleted($deleted++, preg_replace('/-(.*)/', ' $1', $line));
$originUnchanged++;
} else if (preg_match('/^ (.*)/', $line) || $line == '') {
$this->lines[] = new DiffChunkLineUnchanged($originUnchanged++, $destUnchanged++, $line);
$deleted++;
$new++;
} else if (!preg_match('/\\ No newline at end of file/', $line)) {
throw new \Exception(sprintf('GitElephant was unable to parse the line %s', $line));
}
}
} | php | private function parseLines(array $lines)
{
$originUnchanged = $this->originStartLine;
$destUnchanged = $this->destStartLine;
$deleted = $this->originStartLine;
$new = $this->destStartLine;
foreach ($lines as $line) {
if (preg_match('/^\+(.*)/', $line)) {
$this->lines[] = new DiffChunkLineAdded($new++, preg_replace('/\+(.*)/', ' $1', $line));
$destUnchanged++;
} else if (preg_match('/^-(.*)/', $line)) {
$this->lines[] = new DiffChunkLineDeleted($deleted++, preg_replace('/-(.*)/', ' $1', $line));
$originUnchanged++;
} else if (preg_match('/^ (.*)/', $line) || $line == '') {
$this->lines[] = new DiffChunkLineUnchanged($originUnchanged++, $destUnchanged++, $line);
$deleted++;
$new++;
} else if (!preg_match('/\\ No newline at end of file/', $line)) {
throw new \Exception(sprintf('GitElephant was unable to parse the line %s', $line));
}
}
} | [
"private",
"function",
"parseLines",
"(",
"array",
"$",
"lines",
")",
"{",
"$",
"originUnchanged",
"=",
"$",
"this",
"->",
"originStartLine",
";",
"$",
"destUnchanged",
"=",
"$",
"this",
"->",
"destStartLine",
";",
"$",
"deleted",
"=",
"$",
"this",
"->",
... | Parse lines
@param array $lines output lines
@throws \Exception | [
"Parse",
"lines"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Objects/Diff/DiffChunk.php#L100-L122 |
matteosister/GitElephant | src/GitElephant/Objects/Diff/DiffChunk.php | DiffChunk.getLinesNumbers | private function getLinesNumbers(string $line)
{
$matches = [];
preg_match('/@@ -(.*) \+(.*) @@?(.*)/', $line, $matches);
if (!strpos($matches[1], ',')) {
// one line
$this->originStartLine = $matches[1];
$this->originEndLine = $matches[1];
} else {
list($this->originStartLine, $this->originEndLine) = explode(',', $matches[1]);
}
if (!strpos($matches[2], ',')) {
// one line
$this->destStartLine = $matches[2];
$this->destEndLine = $matches[2];
} else {
list($this->destStartLine, $this->destEndLine) = explode(',', $matches[2]);
}
} | php | private function getLinesNumbers(string $line)
{
$matches = [];
preg_match('/@@ -(.*) \+(.*) @@?(.*)/', $line, $matches);
if (!strpos($matches[1], ',')) {
// one line
$this->originStartLine = $matches[1];
$this->originEndLine = $matches[1];
} else {
list($this->originStartLine, $this->originEndLine) = explode(',', $matches[1]);
}
if (!strpos($matches[2], ',')) {
// one line
$this->destStartLine = $matches[2];
$this->destEndLine = $matches[2];
} else {
list($this->destStartLine, $this->destEndLine) = explode(',', $matches[2]);
}
} | [
"private",
"function",
"getLinesNumbers",
"(",
"string",
"$",
"line",
")",
"{",
"$",
"matches",
"=",
"[",
"]",
";",
"preg_match",
"(",
"'/@@ -(.*) \\+(.*) @@?(.*)/'",
",",
"$",
"line",
",",
"$",
"matches",
")",
";",
"if",
"(",
"!",
"strpos",
"(",
"$",
... | Get line numbers
@param string $line a single line | [
"Get",
"line",
"numbers"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Objects/Diff/DiffChunk.php#L129-L148 |
matteosister/GitElephant | src/GitElephant/Objects/Diff/DiffChunk.php | DiffChunk.getHeaderLine | public function getHeaderLine()
{
if (null === $this->headerLine) {
$line = '@@';
$line .= ' -' . $this->getOriginStartLine() . ',' . $this->getOriginEndLine();
$line .= ' +' . $this->getDestStartLine() . ',' . $this->getDestEndLine();
$line .= ' @@';
$this->headerLine = $line;
}
return $this->headerLine;
} | php | public function getHeaderLine()
{
if (null === $this->headerLine) {
$line = '@@';
$line .= ' -' . $this->getOriginStartLine() . ',' . $this->getOriginEndLine();
$line .= ' +' . $this->getDestStartLine() . ',' . $this->getDestEndLine();
$line .= ' @@';
$this->headerLine = $line;
}
return $this->headerLine;
} | [
"public",
"function",
"getHeaderLine",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"headerLine",
")",
"{",
"$",
"line",
"=",
"'@@'",
";",
"$",
"line",
".=",
"' -'",
".",
"$",
"this",
"->",
"getOriginStartLine",
"(",
")",
".",
"','",
... | Get hunk header line
@return string | [
"Get",
"hunk",
"header",
"line"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Objects/Diff/DiffChunk.php#L195-L207 |
matteosister/GitElephant | src/GitElephant/Objects/Diff/DiffChunk.php | DiffChunk.offsetGet | public function offsetGet($offset)
{
return isset($this->lines[$offset]) ? $this->lines[$offset] : null;
} | php | public function offsetGet($offset)
{
return isset($this->lines[$offset]) ? $this->lines[$offset] : null;
} | [
"public",
"function",
"offsetGet",
"(",
"$",
"offset",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"lines",
"[",
"$",
"offset",
"]",
")",
"?",
"$",
"this",
"->",
"lines",
"[",
"$",
"offset",
"]",
":",
"null",
";",
"}"
] | ArrayAccess interface
@param int $offset offset
@return null | [
"ArrayAccess",
"interface"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Objects/Diff/DiffChunk.php#L238-L241 |
matteosister/GitElephant | src/GitElephant/Command/PushCommand.php | PushCommand.push | public function push($remote = 'origin', $branch = 'master', string $args = null)
{
if ($remote instanceof Remote) {
$remote = $remote->getName();
}
if ($branch instanceof Branch) {
$branch = $branch->getName();
}
$this->clearAll();
$this->addCommandName(self::GIT_PUSH_COMMAND);
$this->addCommandSubject($remote);
$this->addCommandSubject2($branch);
if(!is_null($args)) {
$this->addCommandArgument($args);
}
return $this->getCommand();
} | php | public function push($remote = 'origin', $branch = 'master', string $args = null)
{
if ($remote instanceof Remote) {
$remote = $remote->getName();
}
if ($branch instanceof Branch) {
$branch = $branch->getName();
}
$this->clearAll();
$this->addCommandName(self::GIT_PUSH_COMMAND);
$this->addCommandSubject($remote);
$this->addCommandSubject2($branch);
if(!is_null($args)) {
$this->addCommandArgument($args);
}
return $this->getCommand();
} | [
"public",
"function",
"push",
"(",
"$",
"remote",
"=",
"'origin'",
",",
"$",
"branch",
"=",
"'master'",
",",
"string",
"$",
"args",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"remote",
"instanceof",
"Remote",
")",
"{",
"$",
"remote",
"=",
"$",
"remote",
... | @param Remote|string $remote
@param Branch|string $branch
@throws \RuntimeException
@return string | [
"@param",
"Remote|string",
"$remote",
"@param",
"Branch|string",
"$branch"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/PushCommand.php#L52-L70 |
matteosister/GitElephant | src/GitElephant/Objects/LogRange.php | LogRange.createFromCommand | private function createFromCommand(
$refStart,
$refEnd,
$path = null,
int $limit = 15,
int $offset = null,
bool $firstParent = false
)
{
$command = LogRangeCommand::getInstance($this->getRepository())->showLog(
$refStart,
$refEnd,
$path,
$limit,
$offset,
$firstParent
);
$outputLines = $this->getRepository()
->getCaller()
->execute($command, true, $this->getRepository()->getPath())
->getOutputLines(true);
$this->parseOutputLines($outputLines);
} | php | private function createFromCommand(
$refStart,
$refEnd,
$path = null,
int $limit = 15,
int $offset = null,
bool $firstParent = false
)
{
$command = LogRangeCommand::getInstance($this->getRepository())->showLog(
$refStart,
$refEnd,
$path,
$limit,
$offset,
$firstParent
);
$outputLines = $this->getRepository()
->getCaller()
->execute($command, true, $this->getRepository()->getPath())
->getOutputLines(true);
$this->parseOutputLines($outputLines);
} | [
"private",
"function",
"createFromCommand",
"(",
"$",
"refStart",
",",
"$",
"refEnd",
",",
"$",
"path",
"=",
"null",
",",
"int",
"$",
"limit",
"=",
"15",
",",
"int",
"$",
"offset",
"=",
"null",
",",
"bool",
"$",
"firstParent",
"=",
"false",
")",
"{",... | get the commit properties from command
@param string $refStart treeish reference
@param string $refEnd treeish reference
@param string $path path
@param int $limit limit
@param string $offset offset
@param boolean $firstParent first parent
@throws \RuntimeException
@throws \Symfony\Component\Process\Exception\LogicException
@throws \Symfony\Component\Process\Exception\InvalidArgumentException
@throws \Symfony\Component\Process\Exception\RuntimeException
@see ShowCommand::commitInfo | [
"get",
"the",
"commit",
"properties",
"from",
"command"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Objects/LogRange.php#L93-L117 |
matteosister/GitElephant | src/GitElephant/Objects/LogRange.php | LogRange.offsetGet | public function offsetGet($offset)
{
return isset($this->rangeCommits[$offset]) ? $this->rangeCommits[$offset] : null;
} | php | public function offsetGet($offset)
{
return isset($this->rangeCommits[$offset]) ? $this->rangeCommits[$offset] : null;
} | [
"public",
"function",
"offsetGet",
"(",
"$",
"offset",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"rangeCommits",
"[",
"$",
"offset",
"]",
")",
"?",
"$",
"this",
"->",
"rangeCommits",
"[",
"$",
"offset",
"]",
":",
"null",
";",
"}"
] | ArrayAccess interface
@param int $offset offset
@return Commit|null | [
"ArrayAccess",
"interface"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Objects/LogRange.php#L199-L202 |
matteosister/GitElephant | src/GitElephant/Command/PullCommand.php | PullCommand.pull | public function pull($remote = null, $branch = null, $rebase = false)
{
if ($remote instanceof Remote) {
$remote = $remote->getName();
}
if ($branch instanceof Branch) {
$branch = $branch->getName();
}
$this->clearAll();
$this->addCommandName(self::GIT_PULL_COMMAND);
if ($rebase) {
$this->addCommandArgument('--rebase');
}
if (!is_null($remote)) {
$this->addCommandSubject($remote);
}
if (!is_null($branch)) {
$this->addCommandSubject2($branch);
}
return $this->getCommand();
} | php | public function pull($remote = null, $branch = null, $rebase = false)
{
if ($remote instanceof Remote) {
$remote = $remote->getName();
}
if ($branch instanceof Branch) {
$branch = $branch->getName();
}
$this->clearAll();
$this->addCommandName(self::GIT_PULL_COMMAND);
if ($rebase) {
$this->addCommandArgument('--rebase');
}
if (!is_null($remote)) {
$this->addCommandSubject($remote);
}
if (!is_null($branch)) {
$this->addCommandSubject2($branch);
}
return $this->getCommand();
} | [
"public",
"function",
"pull",
"(",
"$",
"remote",
"=",
"null",
",",
"$",
"branch",
"=",
"null",
",",
"$",
"rebase",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"remote",
"instanceof",
"Remote",
")",
"{",
"$",
"remote",
"=",
"$",
"remote",
"->",
"getNam... | @param Remote|string $remote
@param Branch|string $branch
@param bool $rebase
@throws \RuntimeException
@return string | [
"@param",
"Remote|string",
"$remote",
"@param",
"Branch|string",
"$branch",
"@param",
"bool",
"$rebase"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/PullCommand.php#L53-L74 |
matteosister/GitElephant | src/GitElephant/Objects/NodeObject.php | NodeObject.createFromOutputLine | public static function createFromOutputLine(Repository $repository, string $outputLine)
{
$slices = static::getLineSlices($outputLine);
$fullPath = $slices['fullPath'];
if (false === $pos = mb_strrpos($fullPath, '/')) {
// repository root
$path = '';
$name = $fullPath;
} else {
$path = substr($fullPath, 0, $pos);
$name = substr($fullPath, $pos + 1);
}
return new static(
$repository,
$slices['permissions'],
$slices['type'],
$slices['sha'],
$slices['size'],
$name,
$path
);
} | php | public static function createFromOutputLine(Repository $repository, string $outputLine)
{
$slices = static::getLineSlices($outputLine);
$fullPath = $slices['fullPath'];
if (false === $pos = mb_strrpos($fullPath, '/')) {
// repository root
$path = '';
$name = $fullPath;
} else {
$path = substr($fullPath, 0, $pos);
$name = substr($fullPath, $pos + 1);
}
return new static(
$repository,
$slices['permissions'],
$slices['type'],
$slices['sha'],
$slices['size'],
$name,
$path
);
} | [
"public",
"static",
"function",
"createFromOutputLine",
"(",
"Repository",
"$",
"repository",
",",
"string",
"$",
"outputLine",
")",
"{",
"$",
"slices",
"=",
"static",
"::",
"getLineSlices",
"(",
"$",
"outputLine",
")",
";",
"$",
"fullPath",
"=",
"$",
"slice... | create a Object from a single outputLine of the git ls-tree command
@param \GitElephant\Repository $repository repository instance
@param string $outputLine output from ls-tree command
@see LsTreeCommand::tree
@return NodeObject | [
"create",
"a",
"Object",
"from",
"a",
"single",
"outputLine",
"of",
"the",
"git",
"ls",
"-",
"tree",
"command"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Objects/NodeObject.php#L93-L115 |
matteosister/GitElephant | src/GitElephant/Objects/NodeObject.php | NodeObject.getLineSlices | public static function getLineSlices(string $line)
{
preg_match('/^(\d+) (\w+) ([a-z0-9]+) +(\d+|-)\t(.*)$/', $line, $matches);
$permissions = $matches[1];
$type = null;
switch ($matches[2]) {
case NodeObject::TYPE_TREE:
$type = NodeObject::TYPE_TREE;
break;
case NodeObject::TYPE_BLOB:
$type = NodeObject::TYPE_BLOB;
break;
case NodeObject::TYPE_LINK:
$type = NodeObject::TYPE_LINK;
break;
}
$sha = $matches[3];
$size = $matches[4];
$fullPath = $matches[5];
return [
'permissions' => $permissions,
'type' => $type,
'sha' => $sha,
'size' => $size,
'fullPath' => $fullPath,
];
} | php | public static function getLineSlices(string $line)
{
preg_match('/^(\d+) (\w+) ([a-z0-9]+) +(\d+|-)\t(.*)$/', $line, $matches);
$permissions = $matches[1];
$type = null;
switch ($matches[2]) {
case NodeObject::TYPE_TREE:
$type = NodeObject::TYPE_TREE;
break;
case NodeObject::TYPE_BLOB:
$type = NodeObject::TYPE_BLOB;
break;
case NodeObject::TYPE_LINK:
$type = NodeObject::TYPE_LINK;
break;
}
$sha = $matches[3];
$size = $matches[4];
$fullPath = $matches[5];
return [
'permissions' => $permissions,
'type' => $type,
'sha' => $sha,
'size' => $size,
'fullPath' => $fullPath,
];
} | [
"public",
"static",
"function",
"getLineSlices",
"(",
"string",
"$",
"line",
")",
"{",
"preg_match",
"(",
"'/^(\\d+) (\\w+) ([a-z0-9]+) +(\\d+|-)\\t(.*)$/'",
",",
"$",
"line",
",",
"$",
"matches",
")",
";",
"$",
"permissions",
"=",
"$",
"matches",
"[",
"1",
"]... | Take a line and turn it in slices
@param string $line a single line output from the git binary
@return array | [
"Take",
"a",
"line",
"and",
"turn",
"it",
"in",
"slices"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Objects/NodeObject.php#L124-L151 |
matteosister/GitElephant | src/GitElephant/Objects/NodeObject.php | NodeObject.getExtension | public function getExtension()
{
$pos = strrpos($this->name, '.');
if ($pos === false) {
return null;
} else {
return substr($this->name, $pos + 1);
}
} | php | public function getExtension()
{
$pos = strrpos($this->name, '.');
if ($pos === false) {
return null;
} else {
return substr($this->name, $pos + 1);
}
} | [
"public",
"function",
"getExtension",
"(",
")",
"{",
"$",
"pos",
"=",
"strrpos",
"(",
"$",
"this",
"->",
"name",
",",
"'.'",
")",
";",
"if",
"(",
"$",
"pos",
"===",
"false",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"return",
"substr",
"... | get extension if it's a blob
@return string|null | [
"get",
"extension",
"if",
"it",
"s",
"a",
"blob"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Objects/NodeObject.php#L210-L218 |
matteosister/GitElephant | src/GitElephant/Objects/NodeObject.php | NodeObject.getFullPath | public function getFullPath()
{
return rtrim(
'' == $this->path ? $this->name : $this->path . DIRECTORY_SEPARATOR . $this->name,
DIRECTORY_SEPARATOR
);
} | php | public function getFullPath()
{
return rtrim(
'' == $this->path ? $this->name : $this->path . DIRECTORY_SEPARATOR . $this->name,
DIRECTORY_SEPARATOR
);
} | [
"public",
"function",
"getFullPath",
"(",
")",
"{",
"return",
"rtrim",
"(",
"''",
"==",
"$",
"this",
"->",
"path",
"?",
"$",
"this",
"->",
"name",
":",
"$",
"this",
"->",
"path",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"this",
"->",
"name",
",",
"DIREC... | Full path getter
@return string | [
"Full",
"path",
"getter"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Objects/NodeObject.php#L255-L261 |
matteosister/GitElephant | src/GitElephant/Objects/NodeObject.php | NodeObject.revParse | public function revParse(array $options = [])
{
$c = RevParseCommand::getInstance()->revParse($this, $options);
$caller = $this->repository->getCaller();
$caller->execute($c);
return array_map('trim', $caller->getOutputLines(true));
} | php | public function revParse(array $options = [])
{
$c = RevParseCommand::getInstance()->revParse($this, $options);
$caller = $this->repository->getCaller();
$caller->execute($c);
return array_map('trim', $caller->getOutputLines(true));
} | [
"public",
"function",
"revParse",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"c",
"=",
"RevParseCommand",
"::",
"getInstance",
"(",
")",
"->",
"revParse",
"(",
"$",
"this",
",",
"$",
"options",
")",
";",
"$",
"caller",
"=",
"$",
"t... | rev-parse command - often used to return a commit tag.
@param array $options the options to apply to rev-parse
@throws \RuntimeException
@throws \InvalidArgumentException
@throws \Symfony\Component\Process\Exception\RuntimeException
@return array | [
"rev",
"-",
"parse",
"command",
"-",
"often",
"used",
"to",
"return",
"a",
"commit",
"tag",
"."
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Objects/NodeObject.php#L345-L352 |
matteosister/GitElephant | src/GitElephant/Objects/Commit.php | Commit.create | public static function create(Repository $repository, string $message, bool $stageAll = false, $author = null)
{
$repository->getCaller()->execute(MainCommand::getInstance($repository)->commit($message, $stageAll, $author));
return $repository->getCommit();
} | php | public static function create(Repository $repository, string $message, bool $stageAll = false, $author = null)
{
$repository->getCaller()->execute(MainCommand::getInstance($repository)->commit($message, $stageAll, $author));
return $repository->getCommit();
} | [
"public",
"static",
"function",
"create",
"(",
"Repository",
"$",
"repository",
",",
"string",
"$",
"message",
",",
"bool",
"$",
"stageAll",
"=",
"false",
",",
"$",
"author",
"=",
"null",
")",
"{",
"$",
"repository",
"->",
"getCaller",
"(",
")",
"->",
... | factory method to create a commit
@param Repository $repository repository instance
@param string $message commit message
@param bool $stageAll automatically stage the dirty working tree. Alternatively call stage() on the repo
@param string|Author $author override the author for this commit
@throws \RuntimeException
@throws \Symfony\Component\Process\Exception\LogicException
@throws \InvalidArgumentException
@throws \Symfony\Component\Process\Exception\InvalidArgumentException
@throws \Symfony\Component\Process\Exception\RuntimeException
@return Commit | [
"factory",
"method",
"to",
"create",
"a",
"commit"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Objects/Commit.php#L131-L136 |
matteosister/GitElephant | src/GitElephant/Objects/Commit.php | Commit.pick | public static function pick(Repository $repository, $treeish = null)
{
$commit = new self($repository, $treeish);
$commit->createFromCommand();
return $commit;
} | php | public static function pick(Repository $repository, $treeish = null)
{
$commit = new self($repository, $treeish);
$commit->createFromCommand();
return $commit;
} | [
"public",
"static",
"function",
"pick",
"(",
"Repository",
"$",
"repository",
",",
"$",
"treeish",
"=",
"null",
")",
"{",
"$",
"commit",
"=",
"new",
"self",
"(",
"$",
"repository",
",",
"$",
"treeish",
")",
";",
"$",
"commit",
"->",
"createFromCommand",
... | pick an existing commit
@param Repository $repository repository
@param TreeishInterface|string $treeish treeish
@throws \RuntimeException
@throws \Symfony\Component\Process\Exception\RuntimeException
@return Commit | [
"pick",
"an",
"existing",
"commit"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Objects/Commit.php#L148-L154 |
matteosister/GitElephant | src/GitElephant/Objects/Commit.php | Commit.createFromOutputLines | public static function createFromOutputLines(Repository $repository, array $outputLines)
{
$commit = new self($repository);
$commit->parseOutputLines($outputLines);
return $commit;
} | php | public static function createFromOutputLines(Repository $repository, array $outputLines)
{
$commit = new self($repository);
$commit->parseOutputLines($outputLines);
return $commit;
} | [
"public",
"static",
"function",
"createFromOutputLines",
"(",
"Repository",
"$",
"repository",
",",
"array",
"$",
"outputLines",
")",
"{",
"$",
"commit",
"=",
"new",
"self",
"(",
"$",
"repository",
")",
";",
"$",
"commit",
"->",
"parseOutputLines",
"(",
"$",... | static generator to generate a single commit from output of command.show service
@param \GitElephant\Repository $repository repository
@param array $outputLines output lines
@return Commit | [
"static",
"generator",
"to",
"generate",
"a",
"single",
"commit",
"from",
"output",
"of",
"command",
".",
"show",
"service"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Objects/Commit.php#L164-L170 |
matteosister/GitElephant | src/GitElephant/Objects/Commit.php | Commit.createFromCommand | public function createFromCommand()
{
$command = ShowCommand::getInstance($this->getRepository())->showCommit($this->ref);
$outputLines = $this->getCaller()->execute($command, true, $this->getRepository()->getPath())->getOutputLines();
$this->parseOutputLines($outputLines);
} | php | public function createFromCommand()
{
$command = ShowCommand::getInstance($this->getRepository())->showCommit($this->ref);
$outputLines = $this->getCaller()->execute($command, true, $this->getRepository()->getPath())->getOutputLines();
$this->parseOutputLines($outputLines);
} | [
"public",
"function",
"createFromCommand",
"(",
")",
"{",
"$",
"command",
"=",
"ShowCommand",
"::",
"getInstance",
"(",
"$",
"this",
"->",
"getRepository",
"(",
")",
")",
"->",
"showCommit",
"(",
"$",
"this",
"->",
"ref",
")",
";",
"$",
"outputLines",
"=... | get the commit properties from command
@see ShowCommand::commitInfo | [
"get",
"the",
"commit",
"properties",
"from",
"command"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Objects/Commit.php#L177-L182 |
matteosister/GitElephant | src/GitElephant/Objects/Commit.php | Commit.getContainedIn | public function getContainedIn()
{
$command = BranchCommand::getInstance($this->getRepository())->contains($this->getSha());
return array_map('trim', (array)$this->getCaller()->execute($command)->getOutputLines(true));
} | php | public function getContainedIn()
{
$command = BranchCommand::getInstance($this->getRepository())->contains($this->getSha());
return array_map('trim', (array)$this->getCaller()->execute($command)->getOutputLines(true));
} | [
"public",
"function",
"getContainedIn",
"(",
")",
"{",
"$",
"command",
"=",
"BranchCommand",
"::",
"getInstance",
"(",
"$",
"this",
"->",
"getRepository",
"(",
")",
")",
"->",
"contains",
"(",
"$",
"this",
"->",
"getSha",
"(",
")",
")",
";",
"return",
... | get the branches this commit is contained in
@see BranchCommand::contains | [
"get",
"the",
"branches",
"this",
"commit",
"is",
"contained",
"in"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Objects/Commit.php#L189-L194 |
matteosister/GitElephant | src/GitElephant/Objects/Commit.php | Commit.count | public function count()
{
$command = RevListCommand::getInstance($this->getRepository())->commitPath($this);
return count($this->getCaller()->execute($command)->getOutputLines(true));
} | php | public function count()
{
$command = RevListCommand::getInstance($this->getRepository())->commitPath($this);
return count($this->getCaller()->execute($command)->getOutputLines(true));
} | [
"public",
"function",
"count",
"(",
")",
"{",
"$",
"command",
"=",
"RevListCommand",
"::",
"getInstance",
"(",
"$",
"this",
"->",
"getRepository",
"(",
")",
")",
"->",
"commitPath",
"(",
"$",
"this",
")",
";",
"return",
"count",
"(",
"$",
"this",
"->",... | number of commits that lead to this one
@throws \RuntimeException
@throws \Symfony\Component\Process\Exception\LogicException
@throws \Symfony\Component\Process\Exception\InvalidArgumentException
@throws \Symfony\Component\Process\Exception\RuntimeException
@return int | [
"number",
"of",
"commits",
"that",
"lead",
"to",
"this",
"one"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Objects/Commit.php#L205-L210 |
matteosister/GitElephant | src/GitElephant/Objects/Commit.php | Commit.parseOutputLines | private function parseOutputLines($outputLines)
{
$message = [];
foreach ($outputLines as $line) {
$matches = [];
if (preg_match('/^commit (\w+)$/', $line, $matches) > 0) {
$this->sha = $matches[1];
}
if (preg_match('/^tree (\w+)$/', $line, $matches) > 0) {
$this->tree = $matches[1];
}
if (preg_match('/^parent (\w+)$/', $line, $matches) > 0) {
$this->parents[] = $matches[1];
}
if (preg_match('/^author (.*) <(.*)> (\d+) (.*)$/', $line, $matches) > 0) {
$author = new Author();
$author->setName($matches[1]);
$author->setEmail($matches[2]);
$this->author = $author;
$date = \DateTime::createFromFormat('U O', $matches[3] . ' ' . $matches[4]);
$date->modify($date->getOffset() . ' seconds');
$this->datetimeAuthor = $date;
}
if (preg_match('/^committer (.*) <(.*)> (\d+) (.*)$/', $line, $matches) > 0) {
$committer = new Author();
$committer->setName($matches[1]);
$committer->setEmail($matches[2]);
$this->committer = $committer;
$date = \DateTime::createFromFormat('U O', $matches[3] . ' ' . $matches[4]);
$date->modify($date->getOffset() . ' seconds');
$this->datetimeCommitter = $date;
}
if (preg_match('/^ (.*)$/', $line, $matches)) {
$message[] = $matches[1];
}
}
$this->message = new Message($message);
} | php | private function parseOutputLines($outputLines)
{
$message = [];
foreach ($outputLines as $line) {
$matches = [];
if (preg_match('/^commit (\w+)$/', $line, $matches) > 0) {
$this->sha = $matches[1];
}
if (preg_match('/^tree (\w+)$/', $line, $matches) > 0) {
$this->tree = $matches[1];
}
if (preg_match('/^parent (\w+)$/', $line, $matches) > 0) {
$this->parents[] = $matches[1];
}
if (preg_match('/^author (.*) <(.*)> (\d+) (.*)$/', $line, $matches) > 0) {
$author = new Author();
$author->setName($matches[1]);
$author->setEmail($matches[2]);
$this->author = $author;
$date = \DateTime::createFromFormat('U O', $matches[3] . ' ' . $matches[4]);
$date->modify($date->getOffset() . ' seconds');
$this->datetimeAuthor = $date;
}
if (preg_match('/^committer (.*) <(.*)> (\d+) (.*)$/', $line, $matches) > 0) {
$committer = new Author();
$committer->setName($matches[1]);
$committer->setEmail($matches[2]);
$this->committer = $committer;
$date = \DateTime::createFromFormat('U O', $matches[3] . ' ' . $matches[4]);
$date->modify($date->getOffset() . ' seconds');
$this->datetimeCommitter = $date;
}
if (preg_match('/^ (.*)$/', $line, $matches)) {
$message[] = $matches[1];
}
}
$this->message = new Message($message);
} | [
"private",
"function",
"parseOutputLines",
"(",
"$",
"outputLines",
")",
"{",
"$",
"message",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"outputLines",
"as",
"$",
"line",
")",
"{",
"$",
"matches",
"=",
"[",
"]",
";",
"if",
"(",
"preg_match",
"(",
"'/^c... | parse the output of a git command showing a commit
@param array $outputLines output lines | [
"parse",
"the",
"output",
"of",
"a",
"git",
"command",
"showing",
"a",
"commit"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Objects/Commit.php#L222-L265 |
matteosister/GitElephant | src/GitElephant/Objects/Commit.php | Commit.getSha | public function getSha(bool $short = false)
{
return $short ? substr($this->sha, 0, 7) : $this->sha;
} | php | public function getSha(bool $short = false)
{
return $short ? substr($this->sha, 0, 7) : $this->sha;
} | [
"public",
"function",
"getSha",
"(",
"bool",
"$",
"short",
"=",
"false",
")",
"{",
"return",
"$",
"short",
"?",
"substr",
"(",
"$",
"this",
"->",
"sha",
",",
"0",
",",
"7",
")",
":",
"$",
"this",
"->",
"sha",
";",
"}"
] | sha getter
@param bool $short short version
@return mixed | [
"sha",
"getter"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Objects/Commit.php#L362-L365 |
matteosister/GitElephant | src/GitElephant/Objects/Commit.php | Commit.tagged | public function tagged()
{
$result = false;
/** @var Tag $tag */
foreach ($this->repository->getTags() as $tag) {
if ($tag->getSha() === $this->getSha()) {
$result = true;
break;
}
}
return $result;
} | php | public function tagged()
{
$result = false;
/** @var Tag $tag */
foreach ($this->repository->getTags() as $tag) {
if ($tag->getSha() === $this->getSha()) {
$result = true;
break;
}
}
return $result;
} | [
"public",
"function",
"tagged",
"(",
")",
"{",
"$",
"result",
"=",
"false",
";",
"/** @var Tag $tag */",
"foreach",
"(",
"$",
"this",
"->",
"repository",
"->",
"getTags",
"(",
")",
"as",
"$",
"tag",
")",
"{",
"if",
"(",
"$",
"tag",
"->",
"getSha",
"(... | Is the commit tagged?
return true if some tag of repository point to this commit
return false otherwise
@return bool | [
"Is",
"the",
"commit",
"tagged?"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Objects/Commit.php#L424-L437 |
matteosister/GitElephant | src/GitElephant/Objects/Commit.php | Commit.getTags | public function getTags()
{
$currentCommitTags = [];
/** @var Tag $tag */
foreach ($this->repository->getTags() as $tag) {
if ($tag->getSha() === $this->getSha()) {
$currentCommitTags[] = $tag;
}
}
return $currentCommitTags;
} | php | public function getTags()
{
$currentCommitTags = [];
/** @var Tag $tag */
foreach ($this->repository->getTags() as $tag) {
if ($tag->getSha() === $this->getSha()) {
$currentCommitTags[] = $tag;
}
}
return $currentCommitTags;
} | [
"public",
"function",
"getTags",
"(",
")",
"{",
"$",
"currentCommitTags",
"=",
"[",
"]",
";",
"/** @var Tag $tag */",
"foreach",
"(",
"$",
"this",
"->",
"repository",
"->",
"getTags",
"(",
")",
"as",
"$",
"tag",
")",
"{",
"if",
"(",
"$",
"tag",
"->",
... | Return Tags that point to this commit
@return Tag[] | [
"Return",
"Tags",
"that",
"point",
"to",
"this",
"commit"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Objects/Commit.php#L444-L456 |
matteosister/GitElephant | src/GitElephant/Status/Status.php | Status.createFromCommand | private function createFromCommand()
{
$command = MainCommand::getInstance($this->repository)->status(true);
$lines = $this->repository->getCaller()->execute($command)->getOutputLines(true);
$this->parseOutputLines($lines);
} | php | private function createFromCommand()
{
$command = MainCommand::getInstance($this->repository)->status(true);
$lines = $this->repository->getCaller()->execute($command)->getOutputLines(true);
$this->parseOutputLines($lines);
} | [
"private",
"function",
"createFromCommand",
"(",
")",
"{",
"$",
"command",
"=",
"MainCommand",
"::",
"getInstance",
"(",
"$",
"this",
"->",
"repository",
")",
"->",
"status",
"(",
"true",
")",
";",
"$",
"lines",
"=",
"$",
"this",
"->",
"repository",
"->"... | create from git command | [
"create",
"from",
"git",
"command"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Status/Status.php#L71-L76 |
matteosister/GitElephant | src/GitElephant/Status/Status.php | Status.parseOutputLines | private function parseOutputLines(array $lines)
{
foreach ($lines as $line) {
preg_match('/([MADRCU\? ])?([MADRCU\? ])?\ "?(\S+)"? ?( -> )?(\S+)?/', $line, $matches);
$x = isset($matches[1]) ? $matches[1] : null;
$y = isset($matches[2]) ? $matches[2] : null;
$file = isset($matches[3]) ? $matches[3] : null;
$renamedFile = isset($matches[4]) ? $matches[4] : null;
$this->files[] = StatusFile::create($x, $y, $file, $renamedFile);
}
} | php | private function parseOutputLines(array $lines)
{
foreach ($lines as $line) {
preg_match('/([MADRCU\? ])?([MADRCU\? ])?\ "?(\S+)"? ?( -> )?(\S+)?/', $line, $matches);
$x = isset($matches[1]) ? $matches[1] : null;
$y = isset($matches[2]) ? $matches[2] : null;
$file = isset($matches[3]) ? $matches[3] : null;
$renamedFile = isset($matches[4]) ? $matches[4] : null;
$this->files[] = StatusFile::create($x, $y, $file, $renamedFile);
}
} | [
"private",
"function",
"parseOutputLines",
"(",
"array",
"$",
"lines",
")",
"{",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"line",
")",
"{",
"preg_match",
"(",
"'/([MADRCU\\? ])?([MADRCU\\? ])?\\ \"?(\\S+)\"? ?( -> )?(\\S+)?/'",
",",
"$",
"line",
",",
"$",
"matches... | create objects from command output
https://www.kernel.org/pub/software/scm/git/docs/git-status.html in the output section
@param array $lines | [
"create",
"objects",
"from",
"command",
"output",
"https",
":",
"//",
"www",
".",
"kernel",
".",
"org",
"/",
"pub",
"/",
"software",
"/",
"scm",
"/",
"git",
"/",
"docs",
"/",
"git",
"-",
"status",
".",
"html",
"in",
"the",
"output",
"section"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Status/Status.php#L155-L165 |
matteosister/GitElephant | src/GitElephant/Status/StatusFile.php | StatusFile.create | public static function create(string $x, string $y, string $name, string $renamed = null)
{
return new self($x, $y, $name, $renamed);
} | php | public static function create(string $x, string $y, string $name, string $renamed = null)
{
return new self($x, $y, $name, $renamed);
} | [
"public",
"static",
"function",
"create",
"(",
"string",
"$",
"x",
",",
"string",
"$",
"y",
",",
"string",
"$",
"name",
",",
"string",
"$",
"renamed",
"=",
"null",
")",
"{",
"return",
"new",
"self",
"(",
"$",
"x",
",",
"$",
"y",
",",
"$",
"name",... | @param string $x X section of the status --porcelain output
@param string $y Y section of the status --porcelain output
@param string $name file name
@param string $renamed new file name (if renamed)
@return StatusFile | [
"@param",
"string",
"$x",
"X",
"section",
"of",
"the",
"status",
"--",
"porcelain",
"output",
"@param",
"string",
"$y",
"Y",
"section",
"of",
"the",
"status",
"--",
"porcelain",
"output",
"@param",
"string",
"$name",
"file",
"name",
"@param",
"string",
"$ren... | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Status/StatusFile.php#L91-L94 |
matteosister/GitElephant | src/GitElephant/Status/StatusFile.php | StatusFile.calculateDescription | public function calculateDescription()
{
$status = $this->x . $this->y;
$matching = [
'/ [MD]/' => 'not updated',
'/M[MD]/' => 'updated in index',
'/A[MD]/' => 'added to index',
'/D[M]/' => 'deleted from index',
'/R[MD]/' => 'renamed in index',
'/C[MD]/' => 'copied in index',
'/[MARC] /' => 'index and work tree matches',
'/[MARC]M/' => 'work tree changed since index',
'/[MARC]D/' => 'deleted in work tree',
'/DD/' => 'unmerged, both deleted',
'/AU/' => 'unmerged, added by us',
'/UD/' => 'unmerged, deleted by them',
'/UA/' => 'unmerged, added by them',
'/DU/' => 'unmerged, deleted by us',
'/AA/' => 'unmerged, both added',
'/UU/' => 'unmerged, both modified',
'/\?\?/' => 'untracked',
'/!!/' => 'ignored',
];
$out = [];
foreach ($matching as $pattern => $label) {
if (preg_match($pattern, $status)) {
$out[] = $label;
}
}
$this->description = implode(', ', $out);
} | php | public function calculateDescription()
{
$status = $this->x . $this->y;
$matching = [
'/ [MD]/' => 'not updated',
'/M[MD]/' => 'updated in index',
'/A[MD]/' => 'added to index',
'/D[M]/' => 'deleted from index',
'/R[MD]/' => 'renamed in index',
'/C[MD]/' => 'copied in index',
'/[MARC] /' => 'index and work tree matches',
'/[MARC]M/' => 'work tree changed since index',
'/[MARC]D/' => 'deleted in work tree',
'/DD/' => 'unmerged, both deleted',
'/AU/' => 'unmerged, added by us',
'/UD/' => 'unmerged, deleted by them',
'/UA/' => 'unmerged, added by them',
'/DU/' => 'unmerged, deleted by us',
'/AA/' => 'unmerged, both added',
'/UU/' => 'unmerged, both modified',
'/\?\?/' => 'untracked',
'/!!/' => 'ignored',
];
$out = [];
foreach ($matching as $pattern => $label) {
if (preg_match($pattern, $status)) {
$out[] = $label;
}
}
$this->description = implode(', ', $out);
} | [
"public",
"function",
"calculateDescription",
"(",
")",
"{",
"$",
"status",
"=",
"$",
"this",
"->",
"x",
".",
"$",
"this",
"->",
"y",
";",
"$",
"matching",
"=",
"[",
"'/ [MD]/'",
"=>",
"'not updated'",
",",
"'/M[MD]/'",
"=>",
"'updated in index'",
",",
"... | description of the status
@return string | [
"description",
"of",
"the",
"status"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Status/StatusFile.php#L139-L170 |
matteosister/GitElephant | src/GitElephant/Command/Caller/CallerSSH2.php | CallerSSH2.execute | public function execute($cmd, $git = true, $cwd = null)
{
if ($git) {
$cmd = $this->getBinaryPath() . ' ' . $cmd;
}
$stream = ssh2_exec($this->resource, $cmd);
stream_set_blocking($stream, 1);
$data = stream_get_contents($stream);
fclose($stream);
// rtrim values
$values = array_map('rtrim', explode(PHP_EOL, $data));
$this->outputLines = $values;
return $this;
} | php | public function execute($cmd, $git = true, $cwd = null)
{
if ($git) {
$cmd = $this->getBinaryPath() . ' ' . $cmd;
}
$stream = ssh2_exec($this->resource, $cmd);
stream_set_blocking($stream, 1);
$data = stream_get_contents($stream);
fclose($stream);
// rtrim values
$values = array_map('rtrim', explode(PHP_EOL, $data));
$this->outputLines = $values;
return $this;
} | [
"public",
"function",
"execute",
"(",
"$",
"cmd",
",",
"$",
"git",
"=",
"true",
",",
"$",
"cwd",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"git",
")",
"{",
"$",
"cmd",
"=",
"$",
"this",
"->",
"getBinaryPath",
"(",
")",
".",
"' '",
".",
"$",
"cmd... | execute a command
@param string $cmd the command
@param bool $git prepend git to the command
@param null|string $cwd directory where the command should be executed
@return CallerInterface | [
"execute",
"a",
"command"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/Caller/CallerSSH2.php#L59-L73 |
matteosister/GitElephant | src/GitElephant/Command/CloneCommand.php | CloneCommand.cloneUrl | public function cloneUrl(string $url, string $to = null, string $repoReference = null, int $depth = null, bool $recursive = false)
{
// get binary version before reset
$v = $this->getBinaryVersion();
$this->clearAll();
$this->addCommandName(static::GIT_CLONE_COMMAND);
$this->addCommandSubject($url);
if (null !== $to) {
$this->addCommandSubject2($to);
}
if (null !== $repoReference) {
// git documentation says the --branch was added in 2.0.0, but it exists undocumented at least back to 1.8.3.1
if (version_compare($v, '1.8.3.1', '<')) {
throw new \RuntimeException(
'Please upgrade to git v1.8.3.1 or newer to support cloning a specific branch. You have ' . $v . '.'
);
}
$this->addCommandArgument('--branch=' . $repoReference);
}
if (null !== $depth) {
$this->addCommandArgument('--depth=' . $depth);
// shallow-submodules is a nice to have feature. Just ignoring if git version not high enough
// It would be nice if this had a logger injected for us to log notices
if (version_compare($v, '2.9.0', '>=') && $recursive && 1 == $depth) {
$this->addCommandArgument('--shallow-submodules');
}
}
if ($recursive) {
$this->addCommandArgument('--recursive');
}
return $this->getCommand();
} | php | public function cloneUrl(string $url, string $to = null, string $repoReference = null, int $depth = null, bool $recursive = false)
{
// get binary version before reset
$v = $this->getBinaryVersion();
$this->clearAll();
$this->addCommandName(static::GIT_CLONE_COMMAND);
$this->addCommandSubject($url);
if (null !== $to) {
$this->addCommandSubject2($to);
}
if (null !== $repoReference) {
// git documentation says the --branch was added in 2.0.0, but it exists undocumented at least back to 1.8.3.1
if (version_compare($v, '1.8.3.1', '<')) {
throw new \RuntimeException(
'Please upgrade to git v1.8.3.1 or newer to support cloning a specific branch. You have ' . $v . '.'
);
}
$this->addCommandArgument('--branch=' . $repoReference);
}
if (null !== $depth) {
$this->addCommandArgument('--depth=' . $depth);
// shallow-submodules is a nice to have feature. Just ignoring if git version not high enough
// It would be nice if this had a logger injected for us to log notices
if (version_compare($v, '2.9.0', '>=') && $recursive && 1 == $depth) {
$this->addCommandArgument('--shallow-submodules');
}
}
if ($recursive) {
$this->addCommandArgument('--recursive');
}
return $this->getCommand();
} | [
"public",
"function",
"cloneUrl",
"(",
"string",
"$",
"url",
",",
"string",
"$",
"to",
"=",
"null",
",",
"string",
"$",
"repoReference",
"=",
"null",
",",
"int",
"$",
"depth",
"=",
"null",
",",
"bool",
"$",
"recursive",
"=",
"false",
")",
"{",
"// ge... | Command to clone a repository
@param string $url repository url
@param string $to where to clone the repo
@param string|null $repoReference Repo reference to clone. Required if performing a shallow clone.
@param int|null $depth Depth of commits to clone
@param bool $recursive Whether to recursively clone submodules.
@throws \RuntimeException
@return string command | [
"Command",
"to",
"clone",
"a",
"repository"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/CloneCommand.php#L57-L93 |
matteosister/GitElephant | src/GitElephant/Command/MvCommand.php | MvCommand.rename | public function rename($source, $target)
{
if ($source instanceof NodeObject) {
if (!$source->isBlob()) {
throw new \InvalidArgumentException("The given object is not a blob, it couldn't be renamed");
}
$sourceName = $source->getFullPath();
} else {
$sourceName = $source;
}
$this->clearAll();
$this->addCommandName(self::MV_COMMAND);
// Skip move or rename actions which would lead to an error condition
$this->addCommandArgument('-k');
$this->addCommandSubject($sourceName);
$this->addCommandSubject2($target);
return $this->getCommand();
} | php | public function rename($source, $target)
{
if ($source instanceof NodeObject) {
if (!$source->isBlob()) {
throw new \InvalidArgumentException("The given object is not a blob, it couldn't be renamed");
}
$sourceName = $source->getFullPath();
} else {
$sourceName = $source;
}
$this->clearAll();
$this->addCommandName(self::MV_COMMAND);
// Skip move or rename actions which would lead to an error condition
$this->addCommandArgument('-k');
$this->addCommandSubject($sourceName);
$this->addCommandSubject2($target);
return $this->getCommand();
} | [
"public",
"function",
"rename",
"(",
"$",
"source",
",",
"$",
"target",
")",
"{",
"if",
"(",
"$",
"source",
"instanceof",
"NodeObject",
")",
"{",
"if",
"(",
"!",
"$",
"source",
"->",
"isBlob",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumen... | @param string|NodeObject $source source name
@param string $target dest name
@throws \RuntimeException
@throws \InvalidArgumentException
@return string | [
"@param",
"string|NodeObject",
"$source",
"source",
"name",
"@param",
"string",
"$target",
"dest",
"name"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/MvCommand.php#L53-L71 |
matteosister/GitElephant | src/GitElephant/Command/StashCommand.php | StashCommand.save | public function save($message = null, $includeUntracked = false, $keepIndex = false)
{
$this->clearAll();
$this->addCommandName(self::STASH_COMMAND . ' save');
if (!is_null($message)) {
$this->addCommandSubject($message);
}
if ($includeUntracked) {
$this->addCommandArgument('--include-untracked');
}
if ($keepIndex) {
$this->addCommandArgument('--keep-index');
}
return $this->getCommand();
} | php | public function save($message = null, $includeUntracked = false, $keepIndex = false)
{
$this->clearAll();
$this->addCommandName(self::STASH_COMMAND . ' save');
if (!is_null($message)) {
$this->addCommandSubject($message);
}
if ($includeUntracked) {
$this->addCommandArgument('--include-untracked');
}
if ($keepIndex) {
$this->addCommandArgument('--keep-index');
}
return $this->getCommand();
} | [
"public",
"function",
"save",
"(",
"$",
"message",
"=",
"null",
",",
"$",
"includeUntracked",
"=",
"false",
",",
"$",
"keepIndex",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"clearAll",
"(",
")",
";",
"$",
"this",
"->",
"addCommandName",
"(",
"self",
... | Save your local modifications to a new stash, and run git reset --hard to revert them.
@param string|null $message
@param boolean $includeUntracked
@param boolean $keepIndex
@return string | [
"Save",
"your",
"local",
"modifications",
"to",
"a",
"new",
"stash",
"and",
"run",
"git",
"reset",
"--",
"hard",
"to",
"revert",
"them",
"."
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/StashCommand.php#L54-L71 |
matteosister/GitElephant | src/GitElephant/Command/StashCommand.php | StashCommand.listStashes | public function listStashes(array $options = null)
{
$this->clearAll();
$this->addCommandName(self::STASH_COMMAND . ' list');
if (null !== $options) {
$this->addCommandSubject($options);
}
return $this->getCommand();
} | php | public function listStashes(array $options = null)
{
$this->clearAll();
$this->addCommandName(self::STASH_COMMAND . ' list');
if (null !== $options) {
$this->addCommandSubject($options);
}
return $this->getCommand();
} | [
"public",
"function",
"listStashes",
"(",
"array",
"$",
"options",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"clearAll",
"(",
")",
";",
"$",
"this",
"->",
"addCommandName",
"(",
"self",
"::",
"STASH_COMMAND",
".",
"' list'",
")",
";",
"if",
"(",
"null"... | Shows stash list
@param array|null $options
@return string | [
"Shows",
"stash",
"list"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/StashCommand.php#L80-L88 |
matteosister/GitElephant | src/GitElephant/Command/StashCommand.php | StashCommand.show | public function show($stash)
{
$stash = $this->normalizeStashName($stash);
$this->clearAll();
$this->addCommandName(self::STASH_COMMAND . ' show');
$this->addCommandSubject($stash);
return $this->getCommand();
} | php | public function show($stash)
{
$stash = $this->normalizeStashName($stash);
$this->clearAll();
$this->addCommandName(self::STASH_COMMAND . ' show');
$this->addCommandSubject($stash);
return $this->getCommand();
} | [
"public",
"function",
"show",
"(",
"$",
"stash",
")",
"{",
"$",
"stash",
"=",
"$",
"this",
"->",
"normalizeStashName",
"(",
"$",
"stash",
")",
";",
"$",
"this",
"->",
"clearAll",
"(",
")",
";",
"$",
"this",
"->",
"addCommandName",
"(",
"self",
"::",
... | Shows details for a specific stash
@param string $stash
@return string | [
"Shows",
"details",
"for",
"a",
"specific",
"stash"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/StashCommand.php#L97-L104 |
matteosister/GitElephant | src/GitElephant/Command/StashCommand.php | StashCommand.apply | public function apply($stash, $index = false)
{
$stash = $this->normalizeStashName($stash);
$this->clearAll();
$this->addCommandName(self::STASH_COMMAND . ' apply');
$this->addCommandSubject($stash);
if ($index) {
$this->addCommandArgument('--index');
}
return $this->getCommand();
} | php | public function apply($stash, $index = false)
{
$stash = $this->normalizeStashName($stash);
$this->clearAll();
$this->addCommandName(self::STASH_COMMAND . ' apply');
$this->addCommandSubject($stash);
if ($index) {
$this->addCommandArgument('--index');
}
return $this->getCommand();
} | [
"public",
"function",
"apply",
"(",
"$",
"stash",
",",
"$",
"index",
"=",
"false",
")",
"{",
"$",
"stash",
"=",
"$",
"this",
"->",
"normalizeStashName",
"(",
"$",
"stash",
")",
";",
"$",
"this",
"->",
"clearAll",
"(",
")",
";",
"$",
"this",
"->",
... | Applies a stash
@param string $stash
@param boolean $index
@return string | [
"Applies",
"a",
"stash"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/StashCommand.php#L130-L140 |
matteosister/GitElephant | src/GitElephant/Command/StashCommand.php | StashCommand.branch | public function branch($branch, $stash)
{
$stash = $this->normalizeStashName($stash);
$this->clearAll();
$this->addCommandName(self::STASH_COMMAND . ' branch');
$this->addCommandSubject($branch);
$this->addCommandSubject2($stash);
return $this->getCommand();
} | php | public function branch($branch, $stash)
{
$stash = $this->normalizeStashName($stash);
$this->clearAll();
$this->addCommandName(self::STASH_COMMAND . ' branch');
$this->addCommandSubject($branch);
$this->addCommandSubject2($stash);
return $this->getCommand();
} | [
"public",
"function",
"branch",
"(",
"$",
"branch",
",",
"$",
"stash",
")",
"{",
"$",
"stash",
"=",
"$",
"this",
"->",
"normalizeStashName",
"(",
"$",
"stash",
")",
";",
"$",
"this",
"->",
"clearAll",
"(",
")",
";",
"$",
"this",
"->",
"addCommandName... | Creates and checks out a new branch named <branchname> starting from the commit at which the <stash> was originally created
@param string $branch
@param string $stash
@return string | [
"Creates",
"and",
"checks",
"out",
"a",
"new",
"branch",
"named",
"<branchname",
">",
"starting",
"from",
"the",
"commit",
"at",
"which",
"the",
"<stash",
">",
"was",
"originally",
"created"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/StashCommand.php#L170-L178 |
matteosister/GitElephant | src/GitElephant/Command/SubmoduleCommand.php | SubmoduleCommand.add | public function add($gitUrl, $path = null)
{
$this->clearAll();
$this->addCommandName(sprintf('%s %s', self::SUBMODULE_COMMAND, self::SUBMODULE_ADD_COMMAND));
$this->addCommandArgument($gitUrl);
if (null !== $path) {
$this->addCommandSubject($path);
}
return $this->getCommand();
} | php | public function add($gitUrl, $path = null)
{
$this->clearAll();
$this->addCommandName(sprintf('%s %s', self::SUBMODULE_COMMAND, self::SUBMODULE_ADD_COMMAND));
$this->addCommandArgument($gitUrl);
if (null !== $path) {
$this->addCommandSubject($path);
}
return $this->getCommand();
} | [
"public",
"function",
"add",
"(",
"$",
"gitUrl",
",",
"$",
"path",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"clearAll",
"(",
")",
";",
"$",
"this",
"->",
"addCommandName",
"(",
"sprintf",
"(",
"'%s %s'",
",",
"self",
"::",
"SUBMODULE_COMMAND",
",",
... | add a submodule
@param string $gitUrl git url of the submodule
@param string $path path to register the submodule to
@throws \RuntimeException
@return string | [
"add",
"a",
"submodule"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/SubmoduleCommand.php#L59-L69 |
matteosister/GitElephant | src/GitElephant/Command/SubmoduleCommand.php | SubmoduleCommand.init | public function init($path = null)
{
$this->clearAll();
$this->addCommandName(sprintf('%s %s', self::SUBMODULE_COMMAND, self::SUBMODULE_INIT_COMMAND));
if (null !== $path) {
$this->addPath($path);
}
return $this->getCommand();
} | php | public function init($path = null)
{
$this->clearAll();
$this->addCommandName(sprintf('%s %s', self::SUBMODULE_COMMAND, self::SUBMODULE_INIT_COMMAND));
if (null !== $path) {
$this->addPath($path);
}
return $this->getCommand();
} | [
"public",
"function",
"init",
"(",
"$",
"path",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"clearAll",
"(",
")",
";",
"$",
"this",
"->",
"addCommandName",
"(",
"sprintf",
"(",
"'%s %s'",
",",
"self",
"::",
"SUBMODULE_COMMAND",
",",
"self",
"::",
"SUBMOD... | initialize a repository's submodules
@param string $path init only submodules at the specified path
@return string | [
"initialize",
"a",
"repository",
"s",
"submodules"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/SubmoduleCommand.php#L78-L87 |
matteosister/GitElephant | src/GitElephant/Command/SubmoduleCommand.php | SubmoduleCommand.update | public function update($recursive = false, $init = false, $force = false, $path = null)
{
$this->clearAll();
$this->addCommandName(sprintf('%s %s', self::SUBMODULE_COMMAND, self::SUBMODULE_UPDATE_COMMAND));
if ($recursive === true) {
$this->addCommandArgument(self::SUBMODULE_OPTION_RECURSIVE);
}
if ($init === true) {
$this->addCommandArgument(self::SUBMODULE_OPTION_INIT);
}
if ($force === true) {
$this->addCommandArgument(self::SUBMODULE_OPTION_FORCE);
}
if ($path !== null) {
$this->addPath($path);
}
return $this->getCommand();
} | php | public function update($recursive = false, $init = false, $force = false, $path = null)
{
$this->clearAll();
$this->addCommandName(sprintf('%s %s', self::SUBMODULE_COMMAND, self::SUBMODULE_UPDATE_COMMAND));
if ($recursive === true) {
$this->addCommandArgument(self::SUBMODULE_OPTION_RECURSIVE);
}
if ($init === true) {
$this->addCommandArgument(self::SUBMODULE_OPTION_INIT);
}
if ($force === true) {
$this->addCommandArgument(self::SUBMODULE_OPTION_FORCE);
}
if ($path !== null) {
$this->addPath($path);
}
return $this->getCommand();
} | [
"public",
"function",
"update",
"(",
"$",
"recursive",
"=",
"false",
",",
"$",
"init",
"=",
"false",
",",
"$",
"force",
"=",
"false",
",",
"$",
"path",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"clearAll",
"(",
")",
";",
"$",
"this",
"->",
"addCo... | update a repository's submodules
@param bool $recursive update recursively
@param bool $init init before update
@param bool $force force the checkout as part of update
@param string $path update only a specific submodule path
@return string | [
"update",
"a",
"repository",
"s",
"submodules"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/SubmoduleCommand.php#L128-L146 |
matteosister/GitElephant | src/GitElephant/Objects/Log.php | Log.createFromOutputLines | public static function createFromOutputLines(Repository $repository, array $outputLines)
{
$log = new self($repository);
$log->parseOutputLines($outputLines);
return $log;
} | php | public static function createFromOutputLines(Repository $repository, array $outputLines)
{
$log = new self($repository);
$log->parseOutputLines($outputLines);
return $log;
} | [
"public",
"static",
"function",
"createFromOutputLines",
"(",
"Repository",
"$",
"repository",
",",
"array",
"$",
"outputLines",
")",
"{",
"$",
"log",
"=",
"new",
"self",
"(",
"$",
"repository",
")",
";",
"$",
"log",
"->",
"parseOutputLines",
"(",
"$",
"ou... | static method to generate standalone log
@param \GitElephant\Repository $repository repo
@param array $outputLines output lines from command.log
@return \GitElephant\Objects\Log | [
"static",
"method",
"to",
"generate",
"standalone",
"log"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Objects/Log.php#L61-L67 |
matteosister/GitElephant | src/GitElephant/Objects/Log.php | Log.createFromCommand | private function createFromCommand($ref, $path = null, int $limit, int $offset = null, bool $firstParent = false)
{
$command = LogCommand::getInstance($this->getRepository())
->showLog($ref, $path, $limit, $offset, $firstParent);
$outputLines = $this->getRepository()
->getCaller()
->execute($command)
->getOutputLines(true);
$this->parseOutputLines($outputLines);
} | php | private function createFromCommand($ref, $path = null, int $limit, int $offset = null, bool $firstParent = false)
{
$command = LogCommand::getInstance($this->getRepository())
->showLog($ref, $path, $limit, $offset, $firstParent);
$outputLines = $this->getRepository()
->getCaller()
->execute($command)
->getOutputLines(true);
$this->parseOutputLines($outputLines);
} | [
"private",
"function",
"createFromCommand",
"(",
"$",
"ref",
",",
"$",
"path",
"=",
"null",
",",
"int",
"$",
"limit",
",",
"int",
"$",
"offset",
"=",
"null",
",",
"bool",
"$",
"firstParent",
"=",
"false",
")",
"{",
"$",
"command",
"=",
"LogCommand",
... | get the commit properties from command
@param string $ref treeish reference
@param string $path path
@param int $limit limit
@param string $offset offset
@param boolean $firstParent first parent
@throws \RuntimeException
@throws \Symfony\Component\Process\Exception\LogicException
@throws \Symfony\Component\Process\Exception\InvalidArgumentException
@throws \Symfony\Component\Process\Exception\RuntimeException
@see ShowCommand::commitInfo | [
"get",
"the",
"commit",
"properties",
"from",
"command"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Objects/Log.php#L107-L118 |
matteosister/GitElephant | src/GitElephant/Objects/Log.php | Log.offsetGet | public function offsetGet($offset)
{
return isset($this->commits[$offset]) ? $this->commits[$offset] : null;
} | php | public function offsetGet($offset)
{
return isset($this->commits[$offset]) ? $this->commits[$offset] : null;
} | [
"public",
"function",
"offsetGet",
"(",
"$",
"offset",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"commits",
"[",
"$",
"offset",
"]",
")",
"?",
"$",
"this",
"->",
"commits",
"[",
"$",
"offset",
"]",
":",
"null",
";",
"}"
] | ArrayAccess interface
@param int $offset offset
@return Commit|null | [
"ArrayAccess",
"interface"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Objects/Log.php#L191-L194 |
matteosister/GitElephant | src/GitElephant/Command/ResetCommand.php | ResetCommand.reset | public function reset($arg = null, array $options = array())
{
$this->clearAll();
$this->addCommandName(self::GIT_RESET_COMMAND);
// if there are options add them.
if (! is_null($options)) {
foreach ($options as $option) {
$this->addCommandArgument($option);
}
}
if($arg!=null){
$this->addCommandSubject2($arg);
}
return $this->getCommand();
} | php | public function reset($arg = null, array $options = array())
{
$this->clearAll();
$this->addCommandName(self::GIT_RESET_COMMAND);
// if there are options add them.
if (! is_null($options)) {
foreach ($options as $option) {
$this->addCommandArgument($option);
}
}
if($arg!=null){
$this->addCommandSubject2($arg);
}
return $this->getCommand();
} | [
"public",
"function",
"reset",
"(",
"$",
"arg",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"clearAll",
"(",
")",
";",
"$",
"this",
"->",
"addCommandName",
"(",
"self",
"::",
"GIT_RESET_COMMAND",
")... | @param TreeishInterface|Commit|string $arg
@param array $options
@throws \RuntimeException
@return string | [
"@param",
"TreeishInterface|Commit|string",
"$arg",
"@param",
"array",
"$options"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/ResetCommand.php#L42-L57 |
matteosister/GitElephant | src/GitElephant/Command/DiffCommand.php | DiffCommand.diff | public function diff($of, $with = null, $path = null)
{
$this->clearAll();
$this->addCommandName(self::DIFF_COMMAND);
// Instead of the first handful of characters, show the full pre- and post-image blob object names on the
// "index" line when generating patch format output
$this->addCommandArgument('--full-index');
$this->addCommandArgument('--no-color');
// Disallow external diff drivers
$this->addCommandArgument('--no-ext-diff');
// Detect renames
$this->addCommandArgument('-M');
$this->addCommandArgument('--dst-prefix=DST/');
$this->addCommandArgument('--src-prefix=SRC/');
$subject = '';
if (is_null($with)) {
$subject .= $of.'^..'.$of;
} else {
$subject .= $with.'..'.$of;
}
if (! is_null($path)) {
if (!is_string($path)) {
/** @var Object $path */
$path = $path->getPath();
}
$this->addPath($path);
}
$this->addCommandSubject($subject);
return $this->getCommand();
} | php | public function diff($of, $with = null, $path = null)
{
$this->clearAll();
$this->addCommandName(self::DIFF_COMMAND);
// Instead of the first handful of characters, show the full pre- and post-image blob object names on the
// "index" line when generating patch format output
$this->addCommandArgument('--full-index');
$this->addCommandArgument('--no-color');
// Disallow external diff drivers
$this->addCommandArgument('--no-ext-diff');
// Detect renames
$this->addCommandArgument('-M');
$this->addCommandArgument('--dst-prefix=DST/');
$this->addCommandArgument('--src-prefix=SRC/');
$subject = '';
if (is_null($with)) {
$subject .= $of.'^..'.$of;
} else {
$subject .= $with.'..'.$of;
}
if (! is_null($path)) {
if (!is_string($path)) {
/** @var Object $path */
$path = $path->getPath();
}
$this->addPath($path);
}
$this->addCommandSubject($subject);
return $this->getCommand();
} | [
"public",
"function",
"diff",
"(",
"$",
"of",
",",
"$",
"with",
"=",
"null",
",",
"$",
"path",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"clearAll",
"(",
")",
";",
"$",
"this",
"->",
"addCommandName",
"(",
"self",
"::",
"DIFF_COMMAND",
")",
";",
... | build a diff command
@param TreeishInterface $of the reference to diff
@param TreeishInterface|null $with the source reference to diff with $of, if not specified is the current HEAD
@param null $path the path to diff, if not specified the full repository
@throws \RuntimeException
@return string | [
"build",
"a",
"diff",
"command"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/DiffCommand.php#L55-L89 |
matteosister/GitElephant | src/GitElephant/Command/SubCommandCommand.php | SubCommandCommand.getCommand | public function getCommand()
{
$command = $this->getCommandName();
if (is_null($command)) {
throw new \RuntimeException("commandName must be specified to build a subcommand");
}
$command .= ' ';
$args = $this->getCommandArguments();
if (count($args) > 0) {
$command .= $this->extractArguments($args);
$command .= ' ';
}
$subjects = $this->getCommandSubjects();
if (count($subjects) > 0) {
$command .= implode(' ', array_map('escapeshellarg', $subjects));
}
$command = preg_replace('/\\s{2,}/', ' ', $command);
return trim($command);
} | php | public function getCommand()
{
$command = $this->getCommandName();
if (is_null($command)) {
throw new \RuntimeException("commandName must be specified to build a subcommand");
}
$command .= ' ';
$args = $this->getCommandArguments();
if (count($args) > 0) {
$command .= $this->extractArguments($args);
$command .= ' ';
}
$subjects = $this->getCommandSubjects();
if (count($subjects) > 0) {
$command .= implode(' ', array_map('escapeshellarg', $subjects));
}
$command = preg_replace('/\\s{2,}/', ' ', $command);
return trim($command);
} | [
"public",
"function",
"getCommand",
"(",
")",
"{",
"$",
"command",
"=",
"$",
"this",
"->",
"getCommandName",
"(",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"command",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"commandName must be spec... | Get the sub command
@return string
@throws \RuntimeException | [
"Get",
"the",
"sub",
"command"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/SubCommandCommand.php#L95-L116 |
matteosister/GitElephant | src/GitElephant/Command/LsTreeCommand.php | LsTreeCommand.fullTree | public function fullTree($ref = 'HEAD')
{
$what = $ref;
if ($ref instanceof TreeishInterface) {
$what = $ref->getSha();
}
$this->clearAll();
$this->addCommandName(self::LS_TREE_COMMAND);
// recurse
$this->addCommandArgument('-r');
// show trees
$this->addCommandArgument('-t');
$this->addCommandArgument('-l');
$this->addCommandSubject($what);
return $this->getCommand();
} | php | public function fullTree($ref = 'HEAD')
{
$what = $ref;
if ($ref instanceof TreeishInterface) {
$what = $ref->getSha();
}
$this->clearAll();
$this->addCommandName(self::LS_TREE_COMMAND);
// recurse
$this->addCommandArgument('-r');
// show trees
$this->addCommandArgument('-t');
$this->addCommandArgument('-l');
$this->addCommandSubject($what);
return $this->getCommand();
} | [
"public",
"function",
"fullTree",
"(",
"$",
"ref",
"=",
"'HEAD'",
")",
"{",
"$",
"what",
"=",
"$",
"ref",
";",
"if",
"(",
"$",
"ref",
"instanceof",
"TreeishInterface",
")",
"{",
"$",
"what",
"=",
"$",
"ref",
"->",
"getSha",
"(",
")",
";",
"}",
"$... | build a ls-tree command
@param string|Branch $ref The reference to build the tree from
@throws \RuntimeException
@return string | [
"build",
"a",
"ls",
"-",
"tree",
"command"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/LsTreeCommand.php#L55-L71 |
matteosister/GitElephant | src/GitElephant/Command/LsTreeCommand.php | LsTreeCommand.tree | public function tree($ref = 'HEAD', $path = null)
{
if ($path instanceof NodeObject) {
$subjectPath = $path->getFullPath() . ($path->isTree() ? '/' : '');
}
else {
$subjectPath = $path;
}
$what = $ref;
if ($ref instanceof TreeishInterface) {
$what = $ref->getSha();
}
$this->clearAll();
$this->addCommandName(self::LS_TREE_COMMAND);
$this->addCommandArgument('-l');
$subject = $what;
$this->addCommandSubject($subject);
$this->addPath($subjectPath);
return $this->getCommand();
} | php | public function tree($ref = 'HEAD', $path = null)
{
if ($path instanceof NodeObject) {
$subjectPath = $path->getFullPath() . ($path->isTree() ? '/' : '');
}
else {
$subjectPath = $path;
}
$what = $ref;
if ($ref instanceof TreeishInterface) {
$what = $ref->getSha();
}
$this->clearAll();
$this->addCommandName(self::LS_TREE_COMMAND);
$this->addCommandArgument('-l');
$subject = $what;
$this->addCommandSubject($subject);
$this->addPath($subjectPath);
return $this->getCommand();
} | [
"public",
"function",
"tree",
"(",
"$",
"ref",
"=",
"'HEAD'",
",",
"$",
"path",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"path",
"instanceof",
"NodeObject",
")",
"{",
"$",
"subjectPath",
"=",
"$",
"path",
"->",
"getFullPath",
"(",
")",
".",
"(",
"$",... | tree of a given path
@param string $ref reference
@param string|NodeObject $path path
@throws \RuntimeException
@return string | [
"tree",
"of",
"a",
"given",
"path"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/LsTreeCommand.php#L82-L103 |
matteosister/GitElephant | src/GitElephant/Command/LsTreeCommand.php | LsTreeCommand.listAll | public function listAll($ref = null)
{
if (is_null($ref)) {
$ref = 'HEAD';
}
$this->clearAll();
$this->addCommandName(self::LS_TREE_COMMAND);
$this->addCommandSubject($ref);
return $this->getCommand();
} | php | public function listAll($ref = null)
{
if (is_null($ref)) {
$ref = 'HEAD';
}
$this->clearAll();
$this->addCommandName(self::LS_TREE_COMMAND);
$this->addCommandSubject($ref);
return $this->getCommand();
} | [
"public",
"function",
"listAll",
"(",
"$",
"ref",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"ref",
")",
")",
"{",
"$",
"ref",
"=",
"'HEAD'",
";",
"}",
"$",
"this",
"->",
"clearAll",
"(",
")",
";",
"$",
"this",
"->",
"addCommandName",... | build ls-tree command that list all
@param null|string $ref the reference to build the tree from
@throws \RuntimeException
@return string | [
"build",
"ls",
"-",
"tree",
"command",
"that",
"list",
"all"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/LsTreeCommand.php#L113-L124 |
matteosister/GitElephant | src/GitElephant/Command/ShowCommand.php | ShowCommand.showCommit | public function showCommit($ref)
{
$this->clearAll();
$this->addCommandName(self::GIT_SHOW);
$this->addCommandArgument('-s');
$this->addCommandArgument('--pretty=raw');
$this->addCommandArgument('--no-color');
$this->addCommandSubject($ref);
return $this->getCommand();
} | php | public function showCommit($ref)
{
$this->clearAll();
$this->addCommandName(self::GIT_SHOW);
$this->addCommandArgument('-s');
$this->addCommandArgument('--pretty=raw');
$this->addCommandArgument('--no-color');
$this->addCommandSubject($ref);
return $this->getCommand();
} | [
"public",
"function",
"showCommit",
"(",
"$",
"ref",
")",
"{",
"$",
"this",
"->",
"clearAll",
"(",
")",
";",
"$",
"this",
"->",
"addCommandName",
"(",
"self",
"::",
"GIT_SHOW",
")",
";",
"$",
"this",
"->",
"addCommandArgument",
"(",
"'-s'",
")",
";",
... | build the show command
@param string|\GitElephant\Objects\Commit $ref the reference for the show command
@throws \RuntimeException
@return string | [
"build",
"the",
"show",
"command"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/ShowCommand.php#L52-L63 |
matteosister/GitElephant | src/GitElephant/Command/TagCommand.php | TagCommand.create | public function create(string $name, $startPoint = null, $message = null)
{
$this->clearAll();
$this->addCommandName(self::TAG_COMMAND);
if (null !== $message) {
$this->addCommandArgument('-m');
$this->addCommandArgument($message);
}
if (null !== $startPoint) {
$this->addCommandArgument($name);
$this->addCommandSubject($startPoint);
} else {
$this->addCommandSubject($name);
}
return $this->getCommand();
} | php | public function create(string $name, $startPoint = null, $message = null)
{
$this->clearAll();
$this->addCommandName(self::TAG_COMMAND);
if (null !== $message) {
$this->addCommandArgument('-m');
$this->addCommandArgument($message);
}
if (null !== $startPoint) {
$this->addCommandArgument($name);
$this->addCommandSubject($startPoint);
} else {
$this->addCommandSubject($name);
}
return $this->getCommand();
} | [
"public",
"function",
"create",
"(",
"string",
"$",
"name",
",",
"$",
"startPoint",
"=",
"null",
",",
"$",
"message",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"clearAll",
"(",
")",
";",
"$",
"this",
"->",
"addCommandName",
"(",
"self",
"::",
"TAG_CO... | Create a new tag
@param string $name The new tag name
@param string|null $startPoint the new tag start point.
@param null $message the tag message
@throws \RuntimeException
@return string the command | [
"Create",
"a",
"new",
"tag"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/TagCommand.php#L55-L71 |
matteosister/GitElephant | src/GitElephant/Command/TagCommand.php | TagCommand.delete | public function delete($tag)
{
$this->clearAll();
$name = $tag;
if ($tag instanceof Tag) {
$name = $tag->getName();
}
$this->addCommandName(self::TAG_COMMAND);
$this->addCommandArgument('-d');
$this->addCommandSubject($name);
return $this->getCommand();
} | php | public function delete($tag)
{
$this->clearAll();
$name = $tag;
if ($tag instanceof Tag) {
$name = $tag->getName();
}
$this->addCommandName(self::TAG_COMMAND);
$this->addCommandArgument('-d');
$this->addCommandSubject($name);
return $this->getCommand();
} | [
"public",
"function",
"delete",
"(",
"$",
"tag",
")",
"{",
"$",
"this",
"->",
"clearAll",
"(",
")",
";",
"$",
"name",
"=",
"$",
"tag",
";",
"if",
"(",
"$",
"tag",
"instanceof",
"Tag",
")",
"{",
"$",
"name",
"=",
"$",
"tag",
"->",
"getName",
"("... | Delete a tag
@param string|Tag $tag The name of tag, or the Tag instance to delete
@throws \RuntimeException
@return string the command | [
"Delete",
"a",
"tag"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/TagCommand.php#L110-L124 |
matteosister/GitElephant | src/GitElephant/Command/LogCommand.php | LogCommand.showObjectLog | public function showObjectLog(NodeObject $obj, $branch = null, $limit = null, $offset = null)
{
$subject = null;
if (null !== $branch) {
if ($branch instanceof Branch) {
$subject .= $branch->getName();
} else {
$subject .= (string) $branch;
}
}
return $this->showLog($subject, $obj->getFullPath(), $limit, $offset);
} | php | public function showObjectLog(NodeObject $obj, $branch = null, $limit = null, $offset = null)
{
$subject = null;
if (null !== $branch) {
if ($branch instanceof Branch) {
$subject .= $branch->getName();
} else {
$subject .= (string) $branch;
}
}
return $this->showLog($subject, $obj->getFullPath(), $limit, $offset);
} | [
"public",
"function",
"showObjectLog",
"(",
"NodeObject",
"$",
"obj",
",",
"$",
"branch",
"=",
"null",
",",
"$",
"limit",
"=",
"null",
",",
"$",
"offset",
"=",
"null",
")",
"{",
"$",
"subject",
"=",
"null",
";",
"if",
"(",
"null",
"!==",
"$",
"bran... | Build an object log command
@param \GitElephant\Objects\NodeObject $obj the Object to get the log for
@param \GitElephant\Objects\Branch|string|null $branch the branch to consider
@param int|null $limit limit to n entries
@param int|null $offset skip n entries
@throws \RuntimeException
@return string | [
"Build",
"an",
"object",
"log",
"command"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/LogCommand.php#L59-L71 |
matteosister/GitElephant | src/GitElephant/Status/StatusIndex.php | StatusIndex.all | public function all()
{
return new Sequence(
array_filter(
$this->files,
function (StatusFile $statusFile) {
return $statusFile->getIndexStatus() && '?' !== $statusFile->getIndexStatus();
}
)
);
} | php | public function all()
{
return new Sequence(
array_filter(
$this->files,
function (StatusFile $statusFile) {
return $statusFile->getIndexStatus() && '?' !== $statusFile->getIndexStatus();
}
)
);
} | [
"public",
"function",
"all",
"(",
")",
"{",
"return",
"new",
"Sequence",
"(",
"array_filter",
"(",
"$",
"this",
"->",
"files",
",",
"function",
"(",
"StatusFile",
"$",
"statusFile",
")",
"{",
"return",
"$",
"statusFile",
"->",
"getIndexStatus",
"(",
")",
... | all files with modified status in the index
@return Sequence | [
"all",
"files",
"with",
"modified",
"status",
"in",
"the",
"index"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Status/StatusIndex.php#L44-L54 |
matteosister/GitElephant | src/GitElephant/Status/StatusIndex.php | StatusIndex.filterByType | protected function filterByType(string $type)
{
if (!$this->files) {
return new Sequence();
}
return new Sequence(
array_filter(
$this->files,
function (StatusFile $statusFile) use ($type) {
return $type === $statusFile->getIndexStatus();
}
)
);
} | php | protected function filterByType(string $type)
{
if (!$this->files) {
return new Sequence();
}
return new Sequence(
array_filter(
$this->files,
function (StatusFile $statusFile) use ($type) {
return $type === $statusFile->getIndexStatus();
}
)
);
} | [
"protected",
"function",
"filterByType",
"(",
"string",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"files",
")",
"{",
"return",
"new",
"Sequence",
"(",
")",
";",
"}",
"return",
"new",
"Sequence",
"(",
"array_filter",
"(",
"$",
"this",
... | filter files by index status
@param string $type
@return Sequence | [
"filter",
"files",
"by",
"index",
"status"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Status/StatusIndex.php#L63-L77 |
matteosister/GitElephant | src/GitElephant/Command/RevParseCommand.php | RevParseCommand.revParse | public function revParse($arg = null, Array $options = array())
{
$this->clearAll();
$this->addCommandName(self::GIT_REV_PARSE_COMMAND);
// if there are options add them.
if (! is_null($options)) {
foreach ($options as $option) {
$this->addCommandArgument($option);
}
}
if (! is_null($arg)) {
$this->addCommandSubject2($arg);
}
return $this->getCommand();
} | php | public function revParse($arg = null, Array $options = array())
{
$this->clearAll();
$this->addCommandName(self::GIT_REV_PARSE_COMMAND);
// if there are options add them.
if (! is_null($options)) {
foreach ($options as $option) {
$this->addCommandArgument($option);
}
}
if (! is_null($arg)) {
$this->addCommandSubject2($arg);
}
return $this->getCommand();
} | [
"public",
"function",
"revParse",
"(",
"$",
"arg",
"=",
"null",
",",
"Array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"clearAll",
"(",
")",
";",
"$",
"this",
"->",
"addCommandName",
"(",
"self",
"::",
"GIT_REV_PARSE_COMMAND... | @param array $options
@param Branch|string $arg
@throws \RuntimeException
@return string | [
"@param",
"array",
"$options",
"@param",
"Branch|string",
"$arg"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/RevParseCommand.php#L88-L103 |
matteosister/GitElephant | src/GitElephant/Command/MainCommand.php | MainCommand.init | public function init($bare = false)
{
$this->clearAll();
if ($bare) {
$this->addCommandArgument('--bare');
}
$this->addCommandName(self::GIT_INIT);
return $this->getCommand();
} | php | public function init($bare = false)
{
$this->clearAll();
if ($bare) {
$this->addCommandArgument('--bare');
}
$this->addCommandName(self::GIT_INIT);
return $this->getCommand();
} | [
"public",
"function",
"init",
"(",
"$",
"bare",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"clearAll",
"(",
")",
";",
"if",
"(",
"$",
"bare",
")",
"{",
"$",
"this",
"->",
"addCommandArgument",
"(",
"'--bare'",
")",
";",
"}",
"$",
"this",
"->",
"a... | Init the repository
@param bool $bare
@throws \RuntimeException
@return MainCommand | [
"Init",
"the",
"repository"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/MainCommand.php#L62-L71 |
matteosister/GitElephant | src/GitElephant/Command/MainCommand.php | MainCommand.status | public function status($porcelain = false)
{
$this->clearAll();
$this->addCommandName(self::GIT_STATUS);
if ($porcelain) {
$this->addCommandArgument('--porcelain');
} else {
$this->addConfigs(array('color.status' => 'false'));
}
return $this->getCommand();
} | php | public function status($porcelain = false)
{
$this->clearAll();
$this->addCommandName(self::GIT_STATUS);
if ($porcelain) {
$this->addCommandArgument('--porcelain');
} else {
$this->addConfigs(array('color.status' => 'false'));
}
return $this->getCommand();
} | [
"public",
"function",
"status",
"(",
"$",
"porcelain",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"clearAll",
"(",
")",
";",
"$",
"this",
"->",
"addCommandName",
"(",
"self",
"::",
"GIT_STATUS",
")",
";",
"if",
"(",
"$",
"porcelain",
")",
"{",
"$",
... | Get the repository status
@param bool $porcelain
@throws \RuntimeException
@return string | [
"Get",
"the",
"repository",
"status"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/MainCommand.php#L81-L92 |
matteosister/GitElephant | src/GitElephant/Command/MainCommand.php | MainCommand.add | public function add($what = '.')
{
$this->clearAll();
$this->addCommandName(self::GIT_ADD);
$this->addCommandArgument('--all');
$this->addCommandSubject($what);
return $this->getCommand();
} | php | public function add($what = '.')
{
$this->clearAll();
$this->addCommandName(self::GIT_ADD);
$this->addCommandArgument('--all');
$this->addCommandSubject($what);
return $this->getCommand();
} | [
"public",
"function",
"add",
"(",
"$",
"what",
"=",
"'.'",
")",
"{",
"$",
"this",
"->",
"clearAll",
"(",
")",
";",
"$",
"this",
"->",
"addCommandName",
"(",
"self",
"::",
"GIT_ADD",
")",
";",
"$",
"this",
"->",
"addCommandArgument",
"(",
"'--all'",
"... | Add a node to the stage
@param string $what what should be added to the repository
@throws \RuntimeException
@return string | [
"Add",
"a",
"node",
"to",
"the",
"stage"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/MainCommand.php#L102-L110 |
matteosister/GitElephant | src/GitElephant/Command/MainCommand.php | MainCommand.unstage | public function unstage($what)
{
$this->clearAll();
$this->addCommandName(self::GIT_RESET);
$this->addCommandArgument('HEAD');
$this->addPath($what);
return $this->getCommand();
} | php | public function unstage($what)
{
$this->clearAll();
$this->addCommandName(self::GIT_RESET);
$this->addCommandArgument('HEAD');
$this->addPath($what);
return $this->getCommand();
} | [
"public",
"function",
"unstage",
"(",
"$",
"what",
")",
"{",
"$",
"this",
"->",
"clearAll",
"(",
")",
";",
"$",
"this",
"->",
"addCommandName",
"(",
"self",
"::",
"GIT_RESET",
")",
";",
"$",
"this",
"->",
"addCommandArgument",
"(",
"'HEAD'",
")",
";",
... | Remove a node from the stage and put in the working tree
@param string $what what should be removed from the stage
@throws \RuntimeException
@return string | [
"Remove",
"a",
"node",
"from",
"the",
"stage",
"and",
"put",
"in",
"the",
"working",
"tree"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/MainCommand.php#L120-L128 |
matteosister/GitElephant | src/GitElephant/Command/MainCommand.php | MainCommand.commit | public function commit($message, $stageAll = false, $author = null, $allowEmpty = false)
{
$this->clearAll();
if (trim($message) === '' || is_null($message)) {
throw new \InvalidArgumentException(sprintf('You can\'t commit without message'));
}
$this->addCommandName(self::GIT_COMMIT);
if ($stageAll) {
$this->addCommandArgument('-a');
}
if ($author !== null) {
$this->addCommandArgument('--author');
$this->addCommandArgument($author);
}
if ($allowEmpty) {
$this->addCommandArgument('--allow-empty');
}
$this->addCommandArgument('-m');
$this->addCommandSubject($message);
return $this->getCommand();
} | php | public function commit($message, $stageAll = false, $author = null, $allowEmpty = false)
{
$this->clearAll();
if (trim($message) === '' || is_null($message)) {
throw new \InvalidArgumentException(sprintf('You can\'t commit without message'));
}
$this->addCommandName(self::GIT_COMMIT);
if ($stageAll) {
$this->addCommandArgument('-a');
}
if ($author !== null) {
$this->addCommandArgument('--author');
$this->addCommandArgument($author);
}
if ($allowEmpty) {
$this->addCommandArgument('--allow-empty');
}
$this->addCommandArgument('-m');
$this->addCommandSubject($message);
return $this->getCommand();
} | [
"public",
"function",
"commit",
"(",
"$",
"message",
",",
"$",
"stageAll",
"=",
"false",
",",
"$",
"author",
"=",
"null",
",",
"$",
"allowEmpty",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"clearAll",
"(",
")",
";",
"if",
"(",
"trim",
"(",
"$",
"... | Commit
@param string $message the commit message
@param bool $stageAll commit all changes
@param string|Author $author override the author for this commit
@throws \RuntimeException
@throws \InvalidArgumentException
@return string | [
"Commit"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/MainCommand.php#L141-L166 |
matteosister/GitElephant | src/GitElephant/Command/MainCommand.php | MainCommand.checkout | public function checkout($ref)
{
$this->clearAll();
$what = $ref;
if ($ref instanceof Branch) {
$what = $ref->getName();
} elseif ($ref instanceof TreeishInterface) {
$what = $ref->getSha();
}
$this->addCommandName(self::GIT_CHECKOUT);
$this->addCommandArgument('-q');
$this->addCommandSubject($what);
return $this->getCommand();
} | php | public function checkout($ref)
{
$this->clearAll();
$what = $ref;
if ($ref instanceof Branch) {
$what = $ref->getName();
} elseif ($ref instanceof TreeishInterface) {
$what = $ref->getSha();
}
$this->addCommandName(self::GIT_CHECKOUT);
$this->addCommandArgument('-q');
$this->addCommandSubject($what);
return $this->getCommand();
} | [
"public",
"function",
"checkout",
"(",
"$",
"ref",
")",
"{",
"$",
"this",
"->",
"clearAll",
"(",
")",
";",
"$",
"what",
"=",
"$",
"ref",
";",
"if",
"(",
"$",
"ref",
"instanceof",
"Branch",
")",
"{",
"$",
"what",
"=",
"$",
"ref",
"->",
"getName",
... | Checkout a treeish reference
@param string|Branch $ref the reference to checkout
@throws \RuntimeException
@return string | [
"Checkout",
"a",
"treeish",
"reference"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/MainCommand.php#L176-L192 |
matteosister/GitElephant | src/GitElephant/Command/MainCommand.php | MainCommand.move | public function move($from, $to)
{
$this->clearAll();
$from = trim($from);
if (!$this->validatePath($from)) {
throw new \InvalidArgumentException('Invalid source path');
}
$to = trim($to);
if (!$this->validatePath($to)) {
throw new \InvalidArgumentException('Invalid destination path');
}
$this->addCommandName(self::GIT_MOVE);
$this->addCommandSubject($from);
$this->addCommandSubject2($to);
return $this->getCommand();
} | php | public function move($from, $to)
{
$this->clearAll();
$from = trim($from);
if (!$this->validatePath($from)) {
throw new \InvalidArgumentException('Invalid source path');
}
$to = trim($to);
if (!$this->validatePath($to)) {
throw new \InvalidArgumentException('Invalid destination path');
}
$this->addCommandName(self::GIT_MOVE);
$this->addCommandSubject($from);
$this->addCommandSubject2($to);
return $this->getCommand();
} | [
"public",
"function",
"move",
"(",
"$",
"from",
",",
"$",
"to",
")",
"{",
"$",
"this",
"->",
"clearAll",
"(",
")",
";",
"$",
"from",
"=",
"trim",
"(",
"$",
"from",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"validatePath",
"(",
"$",
"from",
... | Move a file/directory
@param string|Object $from source path
@param string|Object $to destination path
@throws \RuntimeException
@throws \InvalidArgumentException
@return string | [
"Move",
"a",
"file",
"/",
"directory"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/MainCommand.php#L204-L223 |
matteosister/GitElephant | src/GitElephant/Command/MainCommand.php | MainCommand.remove | public function remove($path, $recursive, $force)
{
$this->clearAll();
$path = trim($path);
if (!$this->validatePath($path)) {
throw new \InvalidArgumentException('Invalid path');
}
$this->addCommandName(self::GIT_REMOVE);
if ($recursive) {
$this->addCommandArgument('-r');
}
if ($force) {
$this->addCommandArgument('-f');
}
$this->addPath($path);
return $this->getCommand();
} | php | public function remove($path, $recursive, $force)
{
$this->clearAll();
$path = trim($path);
if (!$this->validatePath($path)) {
throw new \InvalidArgumentException('Invalid path');
}
$this->addCommandName(self::GIT_REMOVE);
if ($recursive) {
$this->addCommandArgument('-r');
}
if ($force) {
$this->addCommandArgument('-f');
}
$this->addPath($path);
return $this->getCommand();
} | [
"public",
"function",
"remove",
"(",
"$",
"path",
",",
"$",
"recursive",
",",
"$",
"force",
")",
"{",
"$",
"this",
"->",
"clearAll",
"(",
")",
";",
"$",
"path",
"=",
"trim",
"(",
"$",
"path",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"valida... | Remove a file/directory
@param string|Object $path the path to remove
@param bool $recursive recurse
@param bool $force force
@throws \RuntimeException
@throws \InvalidArgumentException
@return string | [
"Remove",
"a",
"file",
"/",
"directory"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/MainCommand.php#L236-L258 |
matteosister/GitElephant | src/GitElephant/Command/MainCommand.php | MainCommand.validatePath | protected function validatePath($path)
{
if (empty($path)) {
return false;
}
// we are always operating from root directory
// so forbid relative paths
if (false !== strpos($path, '..')) {
return false;
}
return true;
} | php | protected function validatePath($path)
{
if (empty($path)) {
return false;
}
// we are always operating from root directory
// so forbid relative paths
if (false !== strpos($path, '..')) {
return false;
}
return true;
} | [
"protected",
"function",
"validatePath",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"path",
")",
")",
"{",
"return",
"false",
";",
"}",
"// we are always operating from root directory",
"// so forbid relative paths",
"if",
"(",
"false",
"!==",
"st... | Validates a path
@param string $path path
@return bool | [
"Validates",
"a",
"path"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/MainCommand.php#L267-L280 |
matteosister/GitElephant | src/GitElephant/Utilities.php | Utilities.pregSplitArray | public static function pregSplitArray(array $list, string $pattern): array
{
$slices = [];
$index = -1;
foreach ($list as $value) {
if (preg_match($pattern, $value) === 1) {
++$index;
}
if ($index !== -1) {
$slices[$index][] = $value;
}
}
return $slices;
} | php | public static function pregSplitArray(array $list, string $pattern): array
{
$slices = [];
$index = -1;
foreach ($list as $value) {
if (preg_match($pattern, $value) === 1) {
++$index;
}
if ($index !== -1) {
$slices[$index][] = $value;
}
}
return $slices;
} | [
"public",
"static",
"function",
"pregSplitArray",
"(",
"array",
"$",
"list",
",",
"string",
"$",
"pattern",
")",
":",
"array",
"{",
"$",
"slices",
"=",
"[",
"]",
";",
"$",
"index",
"=",
"-",
"1",
";",
"foreach",
"(",
"$",
"list",
"as",
"$",
"value"... | explode an array by lines that match a regular expression
@param string[] $list a flat array
@param string $pattern a regular expression
@return string[] | [
"explode",
"an",
"array",
"by",
"lines",
"that",
"match",
"a",
"regular",
"expression"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Utilities.php#L38-L53 |
matteosister/GitElephant | src/GitElephant/Command/LogRangeCommand.php | LogRangeCommand.showLog | public function showLog($refStart, $refEnd, $path = null, $limit = null, $offset = null, $firstParent = false)
{
$this->clearAll();
$this->addCommandName(self::GIT_LOG);
$this->addCommandArgument('-s');
$this->addCommandArgument('--pretty=raw');
$this->addCommandArgument('--no-color');
if (null !== $limit) {
$limit = (int)$limit;
$this->addCommandArgument('--max-count=' . $limit);
}
if (null !== $offset) {
$offset = (int)$offset;
$this->addCommandArgument('--skip=' . $offset);
}
if (true === $firstParent) {
$this->addCommandArgument('--first-parent');
}
if ($refStart instanceof TreeishInterface) {
$refStart = $refStart->getSha();
}
if ($refEnd instanceof TreeishInterface) {
$refEnd = $refEnd->getSha();
}
if (null !== $path && !empty($path)) {
$this->addPath($path);
}
$this->addCommandSubject($refStart . '..' . $refEnd);
return $this->getCommand();
} | php | public function showLog($refStart, $refEnd, $path = null, $limit = null, $offset = null, $firstParent = false)
{
$this->clearAll();
$this->addCommandName(self::GIT_LOG);
$this->addCommandArgument('-s');
$this->addCommandArgument('--pretty=raw');
$this->addCommandArgument('--no-color');
if (null !== $limit) {
$limit = (int)$limit;
$this->addCommandArgument('--max-count=' . $limit);
}
if (null !== $offset) {
$offset = (int)$offset;
$this->addCommandArgument('--skip=' . $offset);
}
if (true === $firstParent) {
$this->addCommandArgument('--first-parent');
}
if ($refStart instanceof TreeishInterface) {
$refStart = $refStart->getSha();
}
if ($refEnd instanceof TreeishInterface) {
$refEnd = $refEnd->getSha();
}
if (null !== $path && !empty($path)) {
$this->addPath($path);
}
$this->addCommandSubject($refStart . '..' . $refEnd);
return $this->getCommand();
} | [
"public",
"function",
"showLog",
"(",
"$",
"refStart",
",",
"$",
"refEnd",
",",
"$",
"path",
"=",
"null",
",",
"$",
"limit",
"=",
"null",
",",
"$",
"offset",
"=",
"null",
",",
"$",
"firstParent",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"clearAll... | Build a generic log command
@param \GitElephant\Objects\TreeishInterface|string $refStart the reference range start to build the log for
@param \GitElephant\Objects\TreeishInterface|string $refEnd the reference range end to build the log for
@param string|null $path the physical path to the tree relative
to the repository root
@param int|null $limit limit to n entries
@param int|null $offset skip n entries
@param boolean|false $firstParent skip commits brought in to branch by a merge
@throws \RuntimeException
@return string | [
"Build",
"a",
"generic",
"log",
"command"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/LogRangeCommand.php#L56-L94 |
matteosister/GitElephant | src/GitElephant/Objects/Diff/Diff.php | Diff.create | public static function create(Repository $repository, $commit1 = null, $commit2 = null, string $path = null)
{
$commit = new self($repository);
$commit->createFromCommand($commit1, $commit2, $path);
return $commit;
} | php | public static function create(Repository $repository, $commit1 = null, $commit2 = null, string $path = null)
{
$commit = new self($repository);
$commit->createFromCommand($commit1, $commit2, $path);
return $commit;
} | [
"public",
"static",
"function",
"create",
"(",
"Repository",
"$",
"repository",
",",
"$",
"commit1",
"=",
"null",
",",
"$",
"commit2",
"=",
"null",
",",
"string",
"$",
"path",
"=",
"null",
")",
"{",
"$",
"commit",
"=",
"new",
"self",
"(",
"$",
"repos... | static generator to generate a Diff object
@param \GitElephant\Repository $repository repository
@param null|string|\GitElephant\Objects\Commit $commit1 first commit
@param null|string|\GitElephant\Objects\Commit $commit2 second commit
@param null|string $path path to consider
@throws \RuntimeException
@throws \InvalidArgumentException
@throws \Symfony\Component\Process\Exception\RuntimeException
@return Diff | [
"static",
"generator",
"to",
"generate",
"a",
"Diff",
"object"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Objects/Diff/Diff.php#L66-L72 |
matteosister/GitElephant | src/GitElephant/Objects/Diff/Diff.php | Diff.createFromCommand | public function createFromCommand($commit1 = null, $commit2 = null, $path = null)
{
if (null === $commit1) {
$commit1 = $this->getRepository()->getCommit();
}
if (is_string($commit1)) {
$commit1 = $this->getRepository()->getCommit($commit1);
}
if ($commit2 === null) {
if ($commit1->isRoot()) {
$command = DiffTreeCommand::getInstance($this->repository)->rootDiff($commit1);
} else {
$command = DiffCommand::getInstance($this->repository)->diff($commit1);
}
} else {
if (is_string($commit2)) {
$commit2 = $this->getRepository()->getCommit($commit2);
}
$command = DiffCommand::getInstance($this->repository)->diff($commit1, $commit2, $path);
}
$outputLines = $this->getCaller()->execute($command)->getOutputLines();
$this->parseOutputLines($outputLines);
} | php | public function createFromCommand($commit1 = null, $commit2 = null, $path = null)
{
if (null === $commit1) {
$commit1 = $this->getRepository()->getCommit();
}
if (is_string($commit1)) {
$commit1 = $this->getRepository()->getCommit($commit1);
}
if ($commit2 === null) {
if ($commit1->isRoot()) {
$command = DiffTreeCommand::getInstance($this->repository)->rootDiff($commit1);
} else {
$command = DiffCommand::getInstance($this->repository)->diff($commit1);
}
} else {
if (is_string($commit2)) {
$commit2 = $this->getRepository()->getCommit($commit2);
}
$command = DiffCommand::getInstance($this->repository)->diff($commit1, $commit2, $path);
}
$outputLines = $this->getCaller()->execute($command)->getOutputLines();
$this->parseOutputLines($outputLines);
} | [
"public",
"function",
"createFromCommand",
"(",
"$",
"commit1",
"=",
"null",
",",
"$",
"commit2",
"=",
"null",
",",
"$",
"path",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"commit1",
")",
"{",
"$",
"commit1",
"=",
"$",
"this",
"->",
"get... | get the commit properties from command
@param null $commit1 commit 1
@param null $commit2 commit 2
@param null $path path
@throws \RuntimeException
@throws \Symfony\Component\Process\Exception\InvalidArgumentException
@throws \Symfony\Component\Process\Exception\LogicException
@throws \InvalidArgumentException
@throws \Symfony\Component\Process\Exception\RuntimeException
@see ShowCommand::commitInfo | [
"get",
"the",
"commit",
"properties",
"from",
"command"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Objects/Diff/Diff.php#L102-L127 |
matteosister/GitElephant | src/GitElephant/Objects/Diff/Diff.php | Diff.parseOutputLines | private function parseOutputLines(array $outputLines)
{
$this->diffObjects = [];
$splitArray = Utilities::pregSplitArray($outputLines, '/^diff --git SRC\/(.*) DST\/(.*)$/');
foreach ($splitArray as $diffObjectLines) {
$this->diffObjects[] = new DiffObject($diffObjectLines);
}
} | php | private function parseOutputLines(array $outputLines)
{
$this->diffObjects = [];
$splitArray = Utilities::pregSplitArray($outputLines, '/^diff --git SRC\/(.*) DST\/(.*)$/');
foreach ($splitArray as $diffObjectLines) {
$this->diffObjects[] = new DiffObject($diffObjectLines);
}
} | [
"private",
"function",
"parseOutputLines",
"(",
"array",
"$",
"outputLines",
")",
"{",
"$",
"this",
"->",
"diffObjects",
"=",
"[",
"]",
";",
"$",
"splitArray",
"=",
"Utilities",
"::",
"pregSplitArray",
"(",
"$",
"outputLines",
",",
"'/^diff --git SRC\\/(.*) DST\... | parse the output of a git command showing a commit
@param array $outputLines output lines
@throws \InvalidArgumentException | [
"parse",
"the",
"output",
"of",
"a",
"git",
"command",
"showing",
"a",
"commit"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Objects/Diff/Diff.php#L136-L143 |
matteosister/GitElephant | src/GitElephant/Objects/Diff/Diff.php | Diff.offsetGet | public function offsetGet($offset)
{
return isset($this->diffObjects[$offset]) ? $this->diffObjects[$offset] : null;
} | php | public function offsetGet($offset)
{
return isset($this->diffObjects[$offset]) ? $this->diffObjects[$offset] : null;
} | [
"public",
"function",
"offsetGet",
"(",
"$",
"offset",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"diffObjects",
"[",
"$",
"offset",
"]",
")",
"?",
"$",
"this",
"->",
"diffObjects",
"[",
"$",
"offset",
"]",
":",
"null",
";",
"}"
] | ArrayAccess interface
@param int $offset offset
@return null|mixed | [
"ArrayAccess",
"interface"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Objects/Diff/Diff.php#L192-L195 |
matteosister/GitElephant | src/GitElephant/Command/FetchCommand.php | FetchCommand.fetch | public function fetch($remote = null, $branch = null, Array $options = array())
{
if ($remote instanceof Remote) {
$remote = $remote->getName();
}
if ($branch instanceof Branch) {
$branch = $branch->getName();
}
$normalizedOptions = $this->normalizeOptions($options, $this->fetchCmdSwitchOptions());
$this->clearAll();
$this->addCommandName(self::GIT_FETCH_COMMAND);
foreach ($normalizedOptions as $value) {
$this->addCommandArgument($value);
}
if (!is_null($remote)) {
$this->addCommandSubject($remote);
}
if (!is_null($branch)) {
$this->addCommandSubject2($branch);
}
return $this->getCommand();
} | php | public function fetch($remote = null, $branch = null, Array $options = array())
{
if ($remote instanceof Remote) {
$remote = $remote->getName();
}
if ($branch instanceof Branch) {
$branch = $branch->getName();
}
$normalizedOptions = $this->normalizeOptions($options, $this->fetchCmdSwitchOptions());
$this->clearAll();
$this->addCommandName(self::GIT_FETCH_COMMAND);
foreach ($normalizedOptions as $value) {
$this->addCommandArgument($value);
}
if (!is_null($remote)) {
$this->addCommandSubject($remote);
}
if (!is_null($branch)) {
$this->addCommandSubject2($branch);
}
return $this->getCommand();
} | [
"public",
"function",
"fetch",
"(",
"$",
"remote",
"=",
"null",
",",
"$",
"branch",
"=",
"null",
",",
"Array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"$",
"remote",
"instanceof",
"Remote",
")",
"{",
"$",
"remote",
"=",
"$",
... | @param Remote|string $remote
@param Branch|string $branch
@param array $options
@throws \RuntimeException
@return string | [
"@param",
"Remote|string",
"$remote",
"@param",
"Branch|string",
"$branch",
"@param",
"array",
"$options"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/FetchCommand.php#L54-L79 |
matteosister/GitElephant | src/GitElephant/Command/CatFileCommand.php | CatFileCommand.content | public function content(NodeObject $object, $treeish)
{
$this->clearAll();
if ($treeish instanceof TreeishInterface) {
$sha = $treeish->getSha();
} else {
$sha = $treeish;
}
$this->addCommandName(static::GIT_CAT_FILE);
// pretty format
$this->addCommandArgument('-p');
$this->addCommandSubject($sha . ':' . $object->getFullPath());
return $this->getCommand();
} | php | public function content(NodeObject $object, $treeish)
{
$this->clearAll();
if ($treeish instanceof TreeishInterface) {
$sha = $treeish->getSha();
} else {
$sha = $treeish;
}
$this->addCommandName(static::GIT_CAT_FILE);
// pretty format
$this->addCommandArgument('-p');
$this->addCommandSubject($sha . ':' . $object->getFullPath());
return $this->getCommand();
} | [
"public",
"function",
"content",
"(",
"NodeObject",
"$",
"object",
",",
"$",
"treeish",
")",
"{",
"$",
"this",
"->",
"clearAll",
"(",
")",
";",
"if",
"(",
"$",
"treeish",
"instanceof",
"TreeishInterface",
")",
"{",
"$",
"sha",
"=",
"$",
"treeish",
"->"... | command to show content of a Object at a given Treeish point
@param \GitElephant\Objects\NodeObject $object a Object instance
@param \GitElephant\Objects\TreeishInterface|string $treeish an object with TreeishInterface interface
@throws \RuntimeException
@return string | [
"command",
"to",
"show",
"content",
"of",
"a",
"Object",
"at",
"a",
"given",
"Treeish",
"point"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/CatFileCommand.php#L55-L69 |
matteosister/GitElephant | src/GitElephant/Command/CatFileCommand.php | CatFileCommand.contentBySha | public function contentBySha($sha)
{
$this->clearAll();
$this->addCommandName(static::GIT_CAT_FILE);
$this->addCommandArgument('-p');
$this->addCommandSubject($sha);
return $this->getCommand();
} | php | public function contentBySha($sha)
{
$this->clearAll();
$this->addCommandName(static::GIT_CAT_FILE);
$this->addCommandArgument('-p');
$this->addCommandSubject($sha);
return $this->getCommand();
} | [
"public",
"function",
"contentBySha",
"(",
"$",
"sha",
")",
"{",
"$",
"this",
"->",
"clearAll",
"(",
")",
";",
"$",
"this",
"->",
"addCommandName",
"(",
"static",
"::",
"GIT_CAT_FILE",
")",
";",
"$",
"this",
"->",
"addCommandArgument",
"(",
"'-p'",
")",
... | output an object content given it's sha
@param string $sha
@throws \RuntimeException
@return string | [
"output",
"an",
"object",
"content",
"given",
"it",
"s",
"sha"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/CatFileCommand.php#L79-L87 |
matteosister/GitElephant | src/GitElephant/Command/MergeCommand.php | MergeCommand.merge | public function merge(Branch $with, $message = '', Array $options = array())
{
if (in_array(self::MERGE_OPTION_FF_ONLY, $options) && in_array(self::MERGE_OPTION_NO_FF, $options)) {
throw new \Symfony\Component\Process\Exception\InvalidArgumentException("Invalid options: cannot use flags --ff-only and --no-ff together.");
}
$normalizedOptions = $this->normalizeOptions($options, $this->mergeCmdSwitchOptions());
$this->clearAll();
$this->addCommandName(static::MERGE_COMMAND);
foreach ($normalizedOptions as $value) {
$this->addCommandArgument($value);
}
if (!empty($message)) {
$this->addCommandArgument('-m');
$this->addCommandArgument($message);
}
$this->addCommandSubject($with->getFullRef());
return $this->getCommand();
} | php | public function merge(Branch $with, $message = '', Array $options = array())
{
if (in_array(self::MERGE_OPTION_FF_ONLY, $options) && in_array(self::MERGE_OPTION_NO_FF, $options)) {
throw new \Symfony\Component\Process\Exception\InvalidArgumentException("Invalid options: cannot use flags --ff-only and --no-ff together.");
}
$normalizedOptions = $this->normalizeOptions($options, $this->mergeCmdSwitchOptions());
$this->clearAll();
$this->addCommandName(static::MERGE_COMMAND);
foreach ($normalizedOptions as $value) {
$this->addCommandArgument($value);
}
if (!empty($message)) {
$this->addCommandArgument('-m');
$this->addCommandArgument($message);
}
$this->addCommandSubject($with->getFullRef());
return $this->getCommand();
} | [
"public",
"function",
"merge",
"(",
"Branch",
"$",
"with",
",",
"$",
"message",
"=",
"''",
",",
"Array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"in_array",
"(",
"self",
"::",
"MERGE_OPTION_FF_ONLY",
",",
"$",
"options",
")",
"&&... | Generate a merge command
@param \GitElephant\Objects\Branch $with the branch to merge
@param string $message a message for the merge commit, if merge is 3-way
@param array $options option flags for git merge
@throws \RuntimeException
@return string | [
"Generate",
"a",
"merge",
"command"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Command/MergeCommand.php#L57-L79 |
matteosister/GitElephant | src/GitElephant/Objects/Branch.php | Branch.create | public static function create(Repository $repository, string $name, string $startPoint = null)
{
$repository
->getCaller()
->execute(BranchCommand::getInstance($repository)->create($name, $startPoint));
return new self($repository, $name);
} | php | public static function create(Repository $repository, string $name, string $startPoint = null)
{
$repository
->getCaller()
->execute(BranchCommand::getInstance($repository)->create($name, $startPoint));
return new self($repository, $name);
} | [
"public",
"static",
"function",
"create",
"(",
"Repository",
"$",
"repository",
",",
"string",
"$",
"name",
",",
"string",
"$",
"startPoint",
"=",
"null",
")",
"{",
"$",
"repository",
"->",
"getCaller",
"(",
")",
"->",
"execute",
"(",
"BranchCommand",
"::"... | Creates a new branch on the repository and returns it
@param \GitElephant\Repository $repository repository instance
@param string $name branch name
@param string $startPoint branch to start from
@throws \RuntimeException
@throws \Symfony\Component\Process\Exception\LogicException
@throws \Symfony\Component\Process\Exception\InvalidArgumentException
@throws \Symfony\Component\Process\Exception\RuntimeException
@return \GitElephant\Objects\Branch | [
"Creates",
"a",
"new",
"branch",
"on",
"the",
"repository",
"and",
"returns",
"it"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Objects/Branch.php#L81-L88 |
matteosister/GitElephant | src/GitElephant/Objects/Branch.php | Branch.createFromOutputLine | public static function createFromOutputLine(Repository $repository, string $outputLine)
{
$matches = static::getMatches($outputLine);
$branch = new self($repository, $matches[1]);
$branch->parseOutputLine($outputLine);
return $branch;
} | php | public static function createFromOutputLine(Repository $repository, string $outputLine)
{
$matches = static::getMatches($outputLine);
$branch = new self($repository, $matches[1]);
$branch->parseOutputLine($outputLine);
return $branch;
} | [
"public",
"static",
"function",
"createFromOutputLine",
"(",
"Repository",
"$",
"repository",
",",
"string",
"$",
"outputLine",
")",
"{",
"$",
"matches",
"=",
"static",
"::",
"getMatches",
"(",
"$",
"outputLine",
")",
";",
"$",
"branch",
"=",
"new",
"self",
... | static generator to generate a single commit from output of command.show service
@param \GitElephant\Repository $repository repository
@param string $outputLine output line
@throws \InvalidArgumentException
@return Branch | [
"static",
"generator",
"to",
"generate",
"a",
"single",
"commit",
"from",
"output",
"of",
"command",
".",
"show",
"service"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Objects/Branch.php#L99-L106 |
matteosister/GitElephant | src/GitElephant/Objects/Branch.php | Branch.checkout | public static function checkout(Repository $repository, $name, $create = false)
{
if ($create) {
$branch = self::create($repository, $name);
} else {
$branch = new self($repository, $name);
}
$repository->checkout($branch);
return $branch;
} | php | public static function checkout(Repository $repository, $name, $create = false)
{
if ($create) {
$branch = self::create($repository, $name);
} else {
$branch = new self($repository, $name);
}
$repository->checkout($branch);
return $branch;
} | [
"public",
"static",
"function",
"checkout",
"(",
"Repository",
"$",
"repository",
",",
"$",
"name",
",",
"$",
"create",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"create",
")",
"{",
"$",
"branch",
"=",
"self",
"::",
"create",
"(",
"$",
"repository",
",... | @param \GitElephant\Repository $repository repository instance
@param string|TreeishInterface $name branch name
@param bool $create like checkout -b, create a branch and check it out
@throws \RuntimeException
@throws \Symfony\Component\Process\Exception\RuntimeException
@return Branch | [
"@param",
"\\",
"GitElephant",
"\\",
"Repository",
"$repository",
"repository",
"instance",
"@param",
"string|TreeishInterface",
"$name",
"branch",
"name",
"@param",
"bool",
"$create",
"like",
"checkout",
"-",
"b",
"create",
"a",
"branch",
"and",
"check",
"it",
"o... | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Objects/Branch.php#L117-L128 |
matteosister/GitElephant | src/GitElephant/Objects/Branch.php | Branch.createFromCommand | private function createFromCommand()
{
$command = BranchCommand::getInstance($this->getRepository())->listBranches();
$outputLines = $this->repository->getCaller()->execute($command)->getOutputLines(true);
foreach ($outputLines as $outputLine) {
$matches = static::getMatches($outputLine);
if ($this->name === $matches[1]) {
$this->parseOutputLine($outputLine);
return;
}
}
throw new InvalidBranchNameException(sprintf('The %s branch doesn\'t exists', $this->name));
} | php | private function createFromCommand()
{
$command = BranchCommand::getInstance($this->getRepository())->listBranches();
$outputLines = $this->repository->getCaller()->execute($command)->getOutputLines(true);
foreach ($outputLines as $outputLine) {
$matches = static::getMatches($outputLine);
if ($this->name === $matches[1]) {
$this->parseOutputLine($outputLine);
return;
}
}
throw new InvalidBranchNameException(sprintf('The %s branch doesn\'t exists', $this->name));
} | [
"private",
"function",
"createFromCommand",
"(",
")",
"{",
"$",
"command",
"=",
"BranchCommand",
"::",
"getInstance",
"(",
"$",
"this",
"->",
"getRepository",
"(",
")",
")",
"->",
"listBranches",
"(",
")",
";",
"$",
"outputLines",
"=",
"$",
"this",
"->",
... | get the branch properties from command
@throws \InvalidArgumentException | [
"get",
"the",
"branch",
"properties",
"from",
"command"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Objects/Branch.php#L154-L169 |
matteosister/GitElephant | src/GitElephant/Objects/Branch.php | Branch.parseOutputLine | public function parseOutputLine(string $branchString)
{
if (preg_match('/^\* (.*)/', $branchString, $matches)) {
$this->current = true;
$branchString = substr($branchString, 2);
} else {
$branchString = trim($branchString);
}
$matches = static::getMatches($branchString);
$this->name = $matches[1];
$this->sha = $matches[2];
$this->comment = $matches[3];
} | php | public function parseOutputLine(string $branchString)
{
if (preg_match('/^\* (.*)/', $branchString, $matches)) {
$this->current = true;
$branchString = substr($branchString, 2);
} else {
$branchString = trim($branchString);
}
$matches = static::getMatches($branchString);
$this->name = $matches[1];
$this->sha = $matches[2];
$this->comment = $matches[3];
} | [
"public",
"function",
"parseOutputLine",
"(",
"string",
"$",
"branchString",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/^\\* (.*)/'",
",",
"$",
"branchString",
",",
"$",
"matches",
")",
")",
"{",
"$",
"this",
"->",
"current",
"=",
"true",
";",
"$",
"bran... | parse an output line from the BranchCommand::singleInfo command
@param string $branchString an output line for a branch
@throws \InvalidArgumentException | [
"parse",
"an",
"output",
"line",
"from",
"the",
"BranchCommand",
"::",
"singleInfo",
"command"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Objects/Branch.php#L178-L191 |
matteosister/GitElephant | src/GitElephant/Objects/Branch.php | Branch.getMatches | public static function getMatches(string $branchString)
{
$branchString = trim($branchString);
$regexList = [
'/^\*?\ *?(\S+)\ +(\S{40})\ +(.+)$/',
'/^\*?\ *?\(.*(detached).*\)\ +(\S{40})\ +(.+)$/',
];
$matches = [];
while (empty($matches) and $regex = array_pop($regexList)) {
preg_match($regex, trim($branchString), $matches);
}
if (empty($matches)) {
throw new \InvalidArgumentException(sprintf('the branch string is not valid: %s', $branchString));
}
return array_map('trim', $matches);
} | php | public static function getMatches(string $branchString)
{
$branchString = trim($branchString);
$regexList = [
'/^\*?\ *?(\S+)\ +(\S{40})\ +(.+)$/',
'/^\*?\ *?\(.*(detached).*\)\ +(\S{40})\ +(.+)$/',
];
$matches = [];
while (empty($matches) and $regex = array_pop($regexList)) {
preg_match($regex, trim($branchString), $matches);
}
if (empty($matches)) {
throw new \InvalidArgumentException(sprintf('the branch string is not valid: %s', $branchString));
}
return array_map('trim', $matches);
} | [
"public",
"static",
"function",
"getMatches",
"(",
"string",
"$",
"branchString",
")",
"{",
"$",
"branchString",
"=",
"trim",
"(",
"$",
"branchString",
")",
";",
"$",
"regexList",
"=",
"[",
"'/^\\*?\\ *?(\\S+)\\ +(\\S{40})\\ +(.+)$/'",
",",
"'/^\\*?\\ *?\\(.*(detach... | get the matches from an output line
@param string $branchString branch line output
@throws \InvalidArgumentException
@return array | [
"get",
"the",
"matches",
"from",
"an",
"output",
"line"
] | train | https://github.com/matteosister/GitElephant/blob/b29d0d3efdadd09386e1d6dace0b56f6fa994f72/src/GitElephant/Objects/Branch.php#L201-L220 |
sroze/messenger-enqueue-transport | QueueInteropTransport.php | QueueInteropTransport.receive | public function receive(callable $handler): void
{
$context = $this->contextManager->context();
$destination = $this->getDestination(null);
$queue = $context->createQueue($destination['queue']);
$consumer = $context->createConsumer($queue);
if ($this->debug) {
$this->contextManager->ensureExists($destination);
}
while (!$this->shouldStop) {
try {
if (null === ($interopMessage = $consumer->receive($this->options['receiveTimeout'] ?? 30000))) {
$handler(null);
continue;
}
} catch (\Exception $e) {
if ($this->contextManager->recoverException($e, $destination)) {
continue;
}
throw $e;
}
try {
$handler($this->serializer->decode(array(
'body' => $interopMessage->getBody(),
'headers' => $interopMessage->getHeaders(),
'properties' => $interopMessage->getProperties(),
)));
$consumer->acknowledge($interopMessage);
} catch (RejectMessageException $e) {
$consumer->reject($interopMessage);
} catch (RequeueMessageException $e) {
$consumer->reject($interopMessage, true);
}
}
} | php | public function receive(callable $handler): void
{
$context = $this->contextManager->context();
$destination = $this->getDestination(null);
$queue = $context->createQueue($destination['queue']);
$consumer = $context->createConsumer($queue);
if ($this->debug) {
$this->contextManager->ensureExists($destination);
}
while (!$this->shouldStop) {
try {
if (null === ($interopMessage = $consumer->receive($this->options['receiveTimeout'] ?? 30000))) {
$handler(null);
continue;
}
} catch (\Exception $e) {
if ($this->contextManager->recoverException($e, $destination)) {
continue;
}
throw $e;
}
try {
$handler($this->serializer->decode(array(
'body' => $interopMessage->getBody(),
'headers' => $interopMessage->getHeaders(),
'properties' => $interopMessage->getProperties(),
)));
$consumer->acknowledge($interopMessage);
} catch (RejectMessageException $e) {
$consumer->reject($interopMessage);
} catch (RequeueMessageException $e) {
$consumer->reject($interopMessage, true);
}
}
} | [
"public",
"function",
"receive",
"(",
"callable",
"$",
"handler",
")",
":",
"void",
"{",
"$",
"context",
"=",
"$",
"this",
"->",
"contextManager",
"->",
"context",
"(",
")",
";",
"$",
"destination",
"=",
"$",
"this",
"->",
"getDestination",
"(",
"null",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/sroze/messenger-enqueue-transport/blob/89516be3de37961217c8e665e535a28f521df2c6/QueueInteropTransport.php#L62-L101 |
sroze/messenger-enqueue-transport | QueueInteropTransport.php | QueueInteropTransport.send | public function send(Envelope $envelope): Envelope
{
$context = $this->contextManager->context();
$destination = $this->getDestination($envelope);
$topic = $context->createTopic($destination['topic']);
if ($this->debug) {
$this->contextManager->ensureExists($destination);
}
$encodedMessage = $this->serializer->encode($envelope);
$interopMessage = $context->createMessage(
$encodedMessage['body'],
$encodedMessage['properties'] ?? array(),
$encodedMessage['headers'] ?? array()
);
$this->setMessageMetadata($interopMessage, $envelope);
$producer = $context->createProducer();
if (isset($this->options['deliveryDelay'])) {
if ($producer instanceof DelayStrategyAware) {
$producer->setDelayStrategy($this->options['delayStrategy']);
}
$producer->setDeliveryDelay($this->options['deliveryDelay']);
}
if (isset($this->options['priority'])) {
$producer->setPriority($this->options['priority']);
}
if (isset($this->options['timeToLive'])) {
$producer->setTimeToLive($this->options['timeToLive']);
}
try {
$producer->send($topic, $interopMessage);
} catch (InteropQueueException $e) {
if (!$this->contextManager->recoverException($e, $destination)) {
throw new SendingMessageFailedException($e->getMessage(), null, $e);
}
// The context manager recovered the exception, we re-try.
$envelope = $this->send($envelope);
}
return $envelope;
} | php | public function send(Envelope $envelope): Envelope
{
$context = $this->contextManager->context();
$destination = $this->getDestination($envelope);
$topic = $context->createTopic($destination['topic']);
if ($this->debug) {
$this->contextManager->ensureExists($destination);
}
$encodedMessage = $this->serializer->encode($envelope);
$interopMessage = $context->createMessage(
$encodedMessage['body'],
$encodedMessage['properties'] ?? array(),
$encodedMessage['headers'] ?? array()
);
$this->setMessageMetadata($interopMessage, $envelope);
$producer = $context->createProducer();
if (isset($this->options['deliveryDelay'])) {
if ($producer instanceof DelayStrategyAware) {
$producer->setDelayStrategy($this->options['delayStrategy']);
}
$producer->setDeliveryDelay($this->options['deliveryDelay']);
}
if (isset($this->options['priority'])) {
$producer->setPriority($this->options['priority']);
}
if (isset($this->options['timeToLive'])) {
$producer->setTimeToLive($this->options['timeToLive']);
}
try {
$producer->send($topic, $interopMessage);
} catch (InteropQueueException $e) {
if (!$this->contextManager->recoverException($e, $destination)) {
throw new SendingMessageFailedException($e->getMessage(), null, $e);
}
// The context manager recovered the exception, we re-try.
$envelope = $this->send($envelope);
}
return $envelope;
} | [
"public",
"function",
"send",
"(",
"Envelope",
"$",
"envelope",
")",
":",
"Envelope",
"{",
"$",
"context",
"=",
"$",
"this",
"->",
"contextManager",
"->",
"context",
"(",
")",
";",
"$",
"destination",
"=",
"$",
"this",
"->",
"getDestination",
"(",
"$",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/sroze/messenger-enqueue-transport/blob/89516be3de37961217c8e665e535a28f521df2c6/QueueInteropTransport.php#L106-L153 |
sroze/messenger-enqueue-transport | AmqpContextManager.php | AmqpContextManager.recoverException | public function recoverException(\Exception $exception, array $destination): bool
{
if ($exception instanceof \AMQPQueueException) {
if (404 === $exception->getCode()) {
return $this->ensureExists($destination);
}
}
return false;
} | php | public function recoverException(\Exception $exception, array $destination): bool
{
if ($exception instanceof \AMQPQueueException) {
if (404 === $exception->getCode()) {
return $this->ensureExists($destination);
}
}
return false;
} | [
"public",
"function",
"recoverException",
"(",
"\\",
"Exception",
"$",
"exception",
",",
"array",
"$",
"destination",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"exception",
"instanceof",
"\\",
"AMQPQueueException",
")",
"{",
"if",
"(",
"404",
"===",
"$",
"exc... | {@inheritdoc} | [
"{"
] | train | https://github.com/sroze/messenger-enqueue-transport/blob/89516be3de37961217c8e665e535a28f521df2c6/AmqpContextManager.php#L40-L49 |
sroze/messenger-enqueue-transport | AmqpContextManager.php | AmqpContextManager.ensureExists | public function ensureExists(array $destination): bool
{
if (!$this->context instanceof AmqpContext) {
return false;
}
$topic = $this->context->createTopic($destination['topic']);
$topic->setType($destination['topicOptions']['type'] ?? AmqpTopic::TYPE_FANOUT);
$topicFlags = $destination['topicOptions']['flags'] ?? ((int) $topic->getFlags() | AmqpTopic::FLAG_DURABLE);
$topic->setFlags($topicFlags);
$this->context->declareTopic($topic);
$queue = $this->context->createQueue($destination['queue']);
$queueFlags = $destination['queueOptions']['flags'] ?? ((int) $queue->getFlags() | AmqpQueue::FLAG_DURABLE);
$queue->setFlags($queueFlags);
$this->context->declareQueue($queue);
$this->context->bind(
new AmqpBind($queue, $topic, $destination['queueOptions']['bindingKey'] ?? null)
);
return true;
} | php | public function ensureExists(array $destination): bool
{
if (!$this->context instanceof AmqpContext) {
return false;
}
$topic = $this->context->createTopic($destination['topic']);
$topic->setType($destination['topicOptions']['type'] ?? AmqpTopic::TYPE_FANOUT);
$topicFlags = $destination['topicOptions']['flags'] ?? ((int) $topic->getFlags() | AmqpTopic::FLAG_DURABLE);
$topic->setFlags($topicFlags);
$this->context->declareTopic($topic);
$queue = $this->context->createQueue($destination['queue']);
$queueFlags = $destination['queueOptions']['flags'] ?? ((int) $queue->getFlags() | AmqpQueue::FLAG_DURABLE);
$queue->setFlags($queueFlags);
$this->context->declareQueue($queue);
$this->context->bind(
new AmqpBind($queue, $topic, $destination['queueOptions']['bindingKey'] ?? null)
);
return true;
} | [
"public",
"function",
"ensureExists",
"(",
"array",
"$",
"destination",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"context",
"instanceof",
"AmqpContext",
")",
"{",
"return",
"false",
";",
"}",
"$",
"topic",
"=",
"$",
"this",
"->",
"cont... | {@inheritdoc} | [
"{"
] | train | https://github.com/sroze/messenger-enqueue-transport/blob/89516be3de37961217c8e665e535a28f521df2c6/AmqpContextManager.php#L54-L76 |
pascaldevink/shortuuid | src/ShortUuid.php | ShortUuid.uuid1 | public static function uuid1($node = null, ?int $clockSeq = null) : string
{
$uuid = Uuid::uuid1($node, $clockSeq);
$shortUuid = new self();
return $shortUuid->encode($uuid);
} | php | public static function uuid1($node = null, ?int $clockSeq = null) : string
{
$uuid = Uuid::uuid1($node, $clockSeq);
$shortUuid = new self();
return $shortUuid->encode($uuid);
} | [
"public",
"static",
"function",
"uuid1",
"(",
"$",
"node",
"=",
"null",
",",
"?",
"int",
"$",
"clockSeq",
"=",
"null",
")",
":",
"string",
"{",
"$",
"uuid",
"=",
"Uuid",
"::",
"uuid1",
"(",
"$",
"node",
",",
"$",
"clockSeq",
")",
";",
"$",
"short... | Generate a version 1 UUID from a host ID, sequence number, and the current time and shorten it.
@param int|string $node A 48-bit number representing the hardware address
This number may be represented as an integer or a hexadecimal string.
@param int $clockSeq A 14-bit number used to help avoid duplicates that
could arise when the clock is set backwards in time or if the node ID
changes.
@return string | [
"Generate",
"a",
"version",
"1",
"UUID",
"from",
"a",
"host",
"ID",
"sequence",
"number",
"and",
"the",
"current",
"time",
"and",
"shorten",
"it",
"."
] | train | https://github.com/pascaldevink/shortuuid/blob/1f4aef3d610f6f93c03748b489f12a987a4cbac8/src/ShortUuid.php#L51-L56 |
pascaldevink/shortuuid | src/ShortUuid.php | ShortUuid.uuid4 | public static function uuid4() : string
{
$uuid = Uuid::uuid4();
$shortUuid = new self();
return $shortUuid->encode($uuid);
} | php | public static function uuid4() : string
{
$uuid = Uuid::uuid4();
$shortUuid = new self();
return $shortUuid->encode($uuid);
} | [
"public",
"static",
"function",
"uuid4",
"(",
")",
":",
"string",
"{",
"$",
"uuid",
"=",
"Uuid",
"::",
"uuid4",
"(",
")",
";",
"$",
"shortUuid",
"=",
"new",
"self",
"(",
")",
";",
"return",
"$",
"shortUuid",
"->",
"encode",
"(",
"$",
"uuid",
")",
... | Generate a version 4 (random) UUID and shorten it.
@return string | [
"Generate",
"a",
"version",
"4",
"(",
"random",
")",
"UUID",
"and",
"shorten",
"it",
"."
] | train | https://github.com/pascaldevink/shortuuid/blob/1f4aef3d610f6f93c03748b489f12a987a4cbac8/src/ShortUuid.php#L63-L68 |
pascaldevink/shortuuid | src/ShortUuid.php | ShortUuid.uuid5 | public static function uuid5(string $ns, string $name) : string
{
$uuid = Uuid::uuid5($ns, $name);
$shortUuid = new self();
return $shortUuid->encode($uuid);
} | php | public static function uuid5(string $ns, string $name) : string
{
$uuid = Uuid::uuid5($ns, $name);
$shortUuid = new self();
return $shortUuid->encode($uuid);
} | [
"public",
"static",
"function",
"uuid5",
"(",
"string",
"$",
"ns",
",",
"string",
"$",
"name",
")",
":",
"string",
"{",
"$",
"uuid",
"=",
"Uuid",
"::",
"uuid5",
"(",
"$",
"ns",
",",
"$",
"name",
")",
";",
"$",
"shortUuid",
"=",
"new",
"self",
"("... | Generate a version 5 UUID based on the SHA-1 hash of a namespace
identifier (which is a UUID) and a name (which is a string) and shorten it.
@param string $ns The UUID namespace in which to create the named UUID
@param string $name The name to create a UUID for
@return string | [
"Generate",
"a",
"version",
"5",
"UUID",
"based",
"on",
"the",
"SHA",
"-",
"1",
"hash",
"of",
"a",
"namespace",
"identifier",
"(",
"which",
"is",
"a",
"UUID",
")",
"and",
"a",
"name",
"(",
"which",
"is",
"a",
"string",
")",
"and",
"shorten",
"it",
... | train | https://github.com/pascaldevink/shortuuid/blob/1f4aef3d610f6f93c03748b489f12a987a4cbac8/src/ShortUuid.php#L79-L84 |
pascaldevink/shortuuid | src/ShortUuid.php | ShortUuid.encode | public function encode(UuidInterface $uuid) : string
{
/** @var BigNumber $uuidInteger */
$uuidInteger = $uuid->getInteger();
return $this->numToString($uuidInteger);
} | php | public function encode(UuidInterface $uuid) : string
{
/** @var BigNumber $uuidInteger */
$uuidInteger = $uuid->getInteger();
return $this->numToString($uuidInteger);
} | [
"public",
"function",
"encode",
"(",
"UuidInterface",
"$",
"uuid",
")",
":",
"string",
"{",
"/** @var BigNumber $uuidInteger */",
"$",
"uuidInteger",
"=",
"$",
"uuid",
"->",
"getInteger",
"(",
")",
";",
"return",
"$",
"this",
"->",
"numToString",
"(",
"$",
"... | Encodes the given UUID to a shorter version.
For example:
- 4e52c919-513e-4562-9248-7dd612c6c1ca becomes fpfyRTmt6XeE9ehEKZ5LwF
- 59a3e9ab-6b99-4936-928a-d8b465dd41e0 becomes BnxtX5wGumMUWXmnbey6xH
@param UuidInterface $uuid
@return string
@throws ArithmeticException | [
"Encodes",
"the",
"given",
"UUID",
"to",
"a",
"shorter",
"version",
".",
"For",
"example",
":",
"-",
"4e52c919",
"-",
"513e",
"-",
"4562",
"-",
"9248",
"-",
"7dd612c6c1ca",
"becomes",
"fpfyRTmt6XeE9ehEKZ5LwF",
"-",
"59a3e9ab",
"-",
"6b99",
"-",
"4936",
"-"... | train | https://github.com/pascaldevink/shortuuid/blob/1f4aef3d610f6f93c03748b489f12a987a4cbac8/src/ShortUuid.php#L98-L103 |
pascaldevink/shortuuid | src/ShortUuid.php | ShortUuid.numToString | private function numToString(BigNumber $number) : string
{
$output = '';
while ($number->getValue() > 0) {
$previousNumber = clone $number;
$number = $number->divide($this->alphabetLength);
$digit = $previousNumber->mod($this->alphabetLength);
$output .= $this->alphabet[(int)$digit->getValue()];
}
return $output;
} | php | private function numToString(BigNumber $number) : string
{
$output = '';
while ($number->getValue() > 0) {
$previousNumber = clone $number;
$number = $number->divide($this->alphabetLength);
$digit = $previousNumber->mod($this->alphabetLength);
$output .= $this->alphabet[(int)$digit->getValue()];
}
return $output;
} | [
"private",
"function",
"numToString",
"(",
"BigNumber",
"$",
"number",
")",
":",
"string",
"{",
"$",
"output",
"=",
"''",
";",
"while",
"(",
"$",
"number",
"->",
"getValue",
"(",
")",
">",
"0",
")",
"{",
"$",
"previousNumber",
"=",
"clone",
"$",
"num... | Transforms a given (big) number to a string value, based on the set alphabet.
@param BigNumber $number
@return string
@throws ArithmeticException | [
"Transforms",
"a",
"given",
"(",
"big",
")",
"number",
"to",
"a",
"string",
"value",
"based",
"on",
"the",
"set",
"alphabet",
"."
] | train | https://github.com/pascaldevink/shortuuid/blob/1f4aef3d610f6f93c03748b489f12a987a4cbac8/src/ShortUuid.php#L129-L141 |
pascaldevink/shortuuid | src/ShortUuid.php | ShortUuid.stringToNum | private function stringToNum(string $string) : BigNumber
{
$number = new BigNumber(0);
foreach (str_split(strrev($string)) as $char) {
$number->multiply($this->alphabetLength)->add(array_search($char, $this->alphabet, false));
}
return $number;
} | php | private function stringToNum(string $string) : BigNumber
{
$number = new BigNumber(0);
foreach (str_split(strrev($string)) as $char) {
$number->multiply($this->alphabetLength)->add(array_search($char, $this->alphabet, false));
}
return $number;
} | [
"private",
"function",
"stringToNum",
"(",
"string",
"$",
"string",
")",
":",
"BigNumber",
"{",
"$",
"number",
"=",
"new",
"BigNumber",
"(",
"0",
")",
";",
"foreach",
"(",
"str_split",
"(",
"strrev",
"(",
"$",
"string",
")",
")",
"as",
"$",
"char",
"... | Transforms a given string to a (big) number, based on the set alphabet.
@param string $string
@return BigNumber | [
"Transforms",
"a",
"given",
"string",
"to",
"a",
"(",
"big",
")",
"number",
"based",
"on",
"the",
"set",
"alphabet",
"."
] | train | https://github.com/pascaldevink/shortuuid/blob/1f4aef3d610f6f93c03748b489f12a987a4cbac8/src/ShortUuid.php#L150-L158 |
php-http/multipart-stream-builder | src/MultipartStreamBuilder.php | MultipartStreamBuilder.addResource | public function addResource($name, $resource, array $options = [])
{
$stream = $this->streamFactory->createStream($resource);
// validate options['headers'] exists
if (!isset($options['headers'])) {
$options['headers'] = [];
}
// Try to add filename if it is missing
if (empty($options['filename'])) {
$options['filename'] = null;
$uri = $stream->getMetadata('uri');
if ('php://' !== substr($uri, 0, 6)) {
$options['filename'] = $uri;
}
}
$this->prepareHeaders($name, $stream, $options['filename'], $options['headers']);
$this->data[] = ['contents' => $stream, 'headers' => $options['headers'], 'filename' => $options['filename']];
return $this;
} | php | public function addResource($name, $resource, array $options = [])
{
$stream = $this->streamFactory->createStream($resource);
// validate options['headers'] exists
if (!isset($options['headers'])) {
$options['headers'] = [];
}
// Try to add filename if it is missing
if (empty($options['filename'])) {
$options['filename'] = null;
$uri = $stream->getMetadata('uri');
if ('php://' !== substr($uri, 0, 6)) {
$options['filename'] = $uri;
}
}
$this->prepareHeaders($name, $stream, $options['filename'], $options['headers']);
$this->data[] = ['contents' => $stream, 'headers' => $options['headers'], 'filename' => $options['filename']];
return $this;
} | [
"public",
"function",
"addResource",
"(",
"$",
"name",
",",
"$",
"resource",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"stream",
"=",
"$",
"this",
"->",
"streamFactory",
"->",
"createStream",
"(",
"$",
"resource",
")",
";",
"// valida... | Add a resource to the Multipart Stream.
@param string $name the formpost name
@param string|resource|StreamInterface $resource
@param array $options {
@var array $headers additional headers ['header-name' => 'header-value']
@var string $filename
}
@return MultipartStreamBuilder | [
"Add",
"a",
"resource",
"to",
"the",
"Multipart",
"Stream",
"."
] | train | https://github.com/php-http/multipart-stream-builder/blob/60d37c0d405c36fd5e4693bc0cede613492e68d8/src/MultipartStreamBuilder.php#L59-L81 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.