Skip to content

Implement status operator for reading working tree status#23

Merged
sebastianfeldmann merged 1 commit intosebastianfeldmann:mainfrom
ramsey:feature/operator-status
Apr 3, 2021
Merged

Implement status operator for reading working tree status#23
sebastianfeldmann merged 1 commit intosebastianfeldmann:mainfrom
ramsey:feature/operator-status

Conversation

@ramsey
Copy link
Copy Markdown
Contributor

@ramsey ramsey commented Apr 3, 2021

I'm working on a new feature for CaptainHook that requires inspecting the working tree through git status.

This PR provides git status output inspection, creating an array of Path objects, which can be checked for the current status of that path in the working tree (as compared to the index).

Example

Get the status and filter by paths added to the index.

use SebastianFeldmann\Git;

$repo = new Git\Repository(__DIR__);
$status = $repo->getStatusOperator();

$pathsAddedToIndex = array_filter(
    $status->getWorkingTreeStatus(),
    fn ($path) => $path->isAddedToIndex()
);

foreach ($pathsAddedToIndex as $path) {
    echo $path->getPath() . PHP_EOL;
}

@ramsey
Copy link
Copy Markdown
Contributor Author

ramsey commented Apr 3, 2021

Build is failing when attempting to download the PHPStan Phar from the GitHub API.

Copy link
Copy Markdown
Owner

@sebastianfeldmann sebastianfeldmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it!

Looks really good. Merge incoming :)

@sebastianfeldmann sebastianfeldmann merged commit 426acdd into sebastianfeldmann:main Apr 3, 2021
@ramsey ramsey deleted the feature/operator-status branch April 3, 2021 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants