sweetchuck / git
Git related helpers classes.
1.x-dev
2025-04-19 18:05 UTC
Requires
- php: >=8.3
Requires (Dev)
- ext-dom: *
- ext-json: *
- nuvoleweb/robo-config: ^3.0
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^11.0
- squizlabs/php_codesniffer: ^3.5
- sweetchuck/git-hooks: 2.x-dev
- sweetchuck/robo-git: 4.x-dev
- sweetchuck/robo-phpcs: 4.x-dev
- sweetchuck/robo-phpstan: 3.x-dev
- symfony/error-handler: ^7.0
This package is auto-updated.
Last update: 2025-04-19 18:05:54 UTC
README
Commands
Why use this package instead of \exec()?
Using these commands instead of directly calling \exec()
offers several advantages:
- Structured data handling
Results are parsed into PHP arrays and objects, making them easier to work with than raw command output.
Supported commands
- start a working area
- ✔
git init
- ✔
git clone
- ✔
- work on the current change
- 🛠
git add
- 🛠
git mv
- 🛠
git restore
- 🛠
git rm
- 🛠
git apply
- 🛠
git stash
- 🛠
- examine the history and state
- 🛠
git bisect
- 🛠
git diff
- 🛠
git grep
- 🛠
git log
- 🛠
git show
- ✔
git status
- ✔
git ls-files
- 🛠
- grow, mark and tweak your common history
- 🛠
git backfill
- 🛠
git branch CREATE
- ✔
git branch --list --verbose
- 🛠
git branch MOVE
- 🛠
git branch SET-UPSTREAM
- 🛠
git branch DELETE
- 🛠
git commit
- 🛠
git merge
- 🛠
git rebase
- 🛠
git reset
- 🛠
git switch
- 🛠
git tag CREATE
- ✔
git tag --list --verbose
- 🛠
git tag DELETE
- 🛠
- collaborate
- 🛠
git remote
- ✔
git remote --verbose
- ✔
git remote add
- ✔
git remote rename
- ✔
git remote remove
- ✔
git remote update
- ✔
git remote prune
- 🛠
git remote set-head
- 🛠
git remote set-branches
- 🛠
git remote get-url
- 🛠
git remote set-url
- 🛠
git remote show
- ✔
- 🛠
git fetch
- 🛠
git pull
- 🛠
git push
- 🛠
- config
- ✔
git config list
- ✔
git config get
- ✔
git config set
- ✔
git config unset
- ✔
- other
- ✔
git --version
- ✔
git --exec-path
- 🛠 and lot of other commands
- ✔
Command - GetStatus
The GetStatus
command provides a structured interface to the git status
command.
It allows you to:
- Check the status of files in the working directory and staging area
- Filter by paths
- Get results as structured data instead of raw text output
Command - GetTags
The GetTags
command provides a structured way to retrieve Git tags with various
filtering options.
It wraps the git tag --list
command and allows you to:
- Filter tags by various criteria (contains, points-at, merged)
- Sort tags in different ways
- Parse the results into structured data
stdInput reader
stdInput reader - Supported Git hooks
stdInput reader - Usage
.git/hooks/pre-receive
#!/usr/bin/env php <?php use Sweetchuck\Git\StdInputReader\PreReceiveReader; $reader = new PreReceiveReader(\STDIN); foreach ($reader as $item) { echo 'Old value: ', $item->oldValue, \PHP_EOL; echo 'New value: ', $item->newValue, \PHP_EOL; echo 'Ref name: ', $item->refName, \PHP_EOL; echo '-----------', \PHP_EOL; }