boonebgorges / wp-cli-git-helper

Git helper for wp-cli
35 stars 5 forks source link

Only commit plugin files #4

Closed micahjon closed 7 years ago

micahjon commented 9 years ago

I've been burned a couple times when I've updated a plugin using this helper only to find that it's also committed all unstaged changes in my current directory. Do you know why this would happen? Thanks!

boonebgorges commented 9 years ago

Hm, it shouldn't do that :) The tools tries to run git add only on specified paths: https://github.com/boonebgorges/wp-cli-git-helper/blob/master/wp-cli-git-helper.php#L63 That's a good place to start debugging. If you find the issue, please send a PR or describe it here. Thanks!

On 09/21/15 13:35, Micah Miller-Eshleman wrote:

I've been burned a couple times when I've updated a plugin using this helper only to find that it's also committed all unstaged changes in my current directory. Do you know why this would happen? Thanks!

— Reply to this email directly or view it on GitHub https://github.com/boonebgorges/wp-cli-git-helper/issues/4.

micahjon commented 8 years ago

You're right, the git add works perfectly. I think the issue is the --all flag that's on by default in the $repo->commit( $message ); statement: https://github.com/boonebgorges/wp-cli-git-helper/blob/master/wp-cli-git-helper.php#L73

GitRepo::commit() https://github.com/kbjr/Git.php/blob/master/Git.php#L396

which, if I understand right, automatically stages changed files in the current directory before committing. For instance, if I jump into the wp-content/plugins directory, modify index.php, and do a git commit -av -m "test" the index.php changes will be committed even though I never explicitly ran git add.

I'd be happy to submit a PR if you'd like.

boonebgorges commented 8 years ago

Oh nice. Please do send a PR if you find something that works reliably!

micahjon commented 8 years ago

Awesome, just sent one: #5 I've done some basic testing but am no expert on Git!