https://github.com/sweetchuck/robo-git
Git related Robo tasks
https://github.com/sweetchuck/robo-git
git robo robo-tasks
Last synced: 11 months ago
JSON representation
Git related Robo tasks
- Host: GitHub
- URL: https://github.com/sweetchuck/robo-git
- Owner: Sweetchuck
- Created: 2016-10-09T11:02:27.000Z (over 9 years ago)
- Default Branch: 4.x
- Last Pushed: 2024-12-17T21:06:57.000Z (over 1 year ago)
- Last Synced: 2025-07-04T15:24:11.553Z (12 months ago)
- Topics: git, robo, robo-tasks
- Language: PHP
- Size: 470 KB
- Stars: 3
- Watchers: 4
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Robo task wrapper for Git commands
[](https://circleci.com/gh/Sweetchuck/robo-git/tree/4.x)
[](https://codecov.io/gh/Sweetchuck/robo-git)
The main additional feature compare to the ::taskExec() is that this tasks parse
the stdOutput/stdError and make the result available for the next tasks by
putting it into the `\Robo\State\Data` instance which belongs to the pipeline.
## Install
Run `composer require --dev sweetchuck/robo-git`
## Task - taskGitBranchList()
```php
collectionBuilder()
->addTask(
$this
->taskGitBranchList()
->setWorkingDirectory($dir)
// Available options:
// --all
// --color
// --contains
// --format
// --list
// --merged
// --points-at
// --sort
)
->addCode(function (\Robo\State\Data $data): int {
// Here you can do whatever you want with the branches.
$output = $this->output();
foreach ($data['gitBranches'] as $longName => $branch) {
$output->writeln($longName);
foreach ($branch as $key => $value) {
$output->writeln(" $key = " . var_export($value, true));
}
}
return 0;
});
}
}
```
Run: `$ vendor/bin/robo git:branches`
Example output:
>
refs/heads/1.x
> isCurrentBranch = true
> push = 'refs/remotes/upstream/1.x'
> push.short = 'upstream/1.x'
> refName = 'refs/heads/1.x'
> refName.short = '1.x'
> track = ''
> track.ahead = NULL
> track.behind = NULL
> track.gone = false
> upstream = 'refs/remotes/upstream/1.x'
> upstream.short = 'upstream/1.x'
## Task - taskGitConfigGet()
```php
collectionBuilder()
->addTask(
$this
->taskGitConfigGet()
->setName($name)
)
->addCode(function (\Robo\State\Data $data) use ($name): int {
$key = "git.config.$name";
$this->output()->writeln("$key = {$data[$key]}");
return 0;
});
}
}
```
Run: `$ vendor/bin/robo git:config:get`
Example output:
> `git.config.user.name = Andor`
## Task - taskGitCurrentBranch()
```php
collectionBuilder()
->addTask($this->taskGitCurrentBranch())
->addCode(function (\Robo\State\Data $data): int {
$this->output()->writeln("long = {$data['gitCurrentBranch.long']}");
$this->output()->writeln("short = {$data['gitCurrentBranch.short']}");
return 0;
});
}
}
```
Run: `$ vendor/bin/robo git:current-branch`
Example output:
> long = refs/heads/1.x
> short = 1.x
## Task - taskGitListFiles()
```php
collectionBuilder()
->addTask(
$this
->taskGitListFiles()
->setPaths(['R*.md'])
// Available options:
// -t
// -v
// -z
// --cached
// --deleted
// --directory
// --empty-directory
// --eol
// --exclude
// --exclude-file
// --full-name
// --killed
// --ignored
// --modified
// --others
// --stage
// --resolve-undo
// --unmerged
)
->addCode(function (\Robo\State\Data $data): int {
$output = $this->output();
/** * @var \Sweetchuck\Robo\Git\ListFilesItem $file */
foreach ($data['files'] as $filePath => $file) {
$output->writeln($filePath);
$output->writeln(' status = ' . var_export($file->status, true));
$output->writeln(' objectName = ' . var_export($file->objectName, true));
$output->writeln(' eolInfoI = ' . var_export($file->eolInfoI, true));
$output->writeln(' eolInfoW = ' . var_export($file->eolInfoW, true));
$output->writeln(' eolAttr = ' . var_export($file->eolAttr, true));
$output->writeln(' fileName = ' . var_export($file->fileName, true));
}
return 0;
});
}
}
```
Run: `$ vendor/bin/robo git:list-files`
Example output:
>
README.md
> status = NULL
> objectName = NULL
> eolInfoI = NULL
> eolInfoW = NULL
> eolAttr = NULL
> fileName = 'README.md'
## Task - taskGitListChangedFiles()
@todo
## Task - taskGitListStagedFiles()
@todo
## Task - taskGitNumOfCommitsBetween()
@todo
## Task - taskGitReadStagedFiles()
@todo
## Task - taskGitRemoteList()
@todo
## Task - taskGitStatus()
@todo
## Task - taskGitTagList()
@todo
## Task - taskGitTopLevel()
@todo