fadion / Maneuver

Easily deploy Laravel projects via FTP or SFTP, using Git for versioning
MIT License
174 stars 26 forks source link

Unknown git-diff status: R #27

Closed tbergeron closed 7 years ago

tbergeron commented 7 years ago

When deploying after renaming a file with git, I get this error.

(master) ✗ artisan deploy

+ --------------- § --------------- +
» Server: productionUnknown git-diff status: R

(same thing happens for deploy:list)

This comes from here: https://github.com/fadion/Maneuver/blob/master/src/Fadion/Maneuver/Deploy.php#L104-L114

I guess support for R status needs to be added. I don't mind doing it myself but I'd need some guidance on what should happen when the R status comes in?

Thanks for this great utility, I use it very often and it's the first issue I ever encounter with it! 👍

fadion commented 7 years ago

I'm surprised you're the first to stumble upon this issue, and I've used Maneuver for several projects. Actually the fix should be fairly easy, as there's no need to manage the "R" (Rename) status. Instead, git diff can be instructed to return renames as a combination of delete and add.

I don't have a working setup currently, so if you'll be kind enough to test the following suggestion and send a pull request, it would be terrific.

The diff function at: https://github.com/fadion/Maneuver/blob/master/src/Fadion/Maneuver/Git.php#L150

would need to change to:

public function diff($revision)
{
    if (! $revision) {
        return $this->command('ls-files');
    }

    return $this->command("diff --name-status --no-renames {$revision}... {$this->revision}");
}

I removed the useless elseif, as I have no idea why I had that, and added a --no-renames flag. The latter treats renames as delete+add.

Thanks

tbergeron commented 7 years ago

Wonderful! This fixed my issue, deployments are smooth now! Thanks a lot! PS: I opened a PR so you can integrate this change. Hope this is okay with you, cheers!