Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get an array of changed files? #40

Open
derUli opened this issue Mar 10, 2019 · 3 comments
Open

How to get an array of changed files? #40

derUli opened this issue Mar 10, 2019 · 3 comments
Labels

Comments

@derUli
Copy link

derUli commented Mar 10, 2019

There is the method hasChanges() which returns true, if there are any changed files.
But I don't see a method which returns what files have been changed.
Am I overlooking something?

@janpecha
Copy link
Contributor

Hello, you are right, there is no method which returns what files have been changed. Can you send PR?

@derUli
Copy link
Author

derUli commented Mar 15, 2019

Yes.
I think about the implementation details.
We get filenames and a letter determine the type of status for any file (new file, modified file, deleted file) from git status command line.
example given "M myfile.php" would mean, the already added file myfile.php was changed.

So it makes sense to make getChanges() to return an associative array of filename => Type of status.
Additionally we should have constants for the file status type
GIT_FILE_STATUS_NEW
GIT_FILE_STATUS_CHANGED
GIT_FILE_STATUS_DELETED

Do you confirm with that?

@derUli
Copy link
Author

derUli commented Mar 15, 2019

I implemented a getChanges Method.

#42

Unfortunately i wasn't able to get the tests running on my Windoze machine.
But I verified it's function with a simple php script. Which just calls getChanges() on a repository and shows the output.
You have to extend your tests by yourself.

C:\Users\deruli\Documents\GitHub\git-php>php test.php
array(1) {
  ["src/GitRepository.php"]=>
  string(1) "M"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants