From 72d38fd65ed72b67bfe25cecdefb395222a48eec Mon Sep 17 00:00:00 2001 From: Baki Goxhaj Date: Sat, 15 Feb 2014 11:07:51 +0100 Subject: [PATCH] v1.3.1 - Fixes Fresh Upload Fresh upload was broken on previos dev cicyle. It is now fixed. Requires two checks. fixes #6 --- phploy | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/phploy b/phploy index 201d57c..713d0e9 100644 --- a/phploy +++ b/phploy @@ -246,6 +246,7 @@ class PHPloy $tmpFile = tmpfile(); $filesToUpload = array(); $filesToDelete = array(); + $output = array(); if ($this->isSubmodule) { $this->dotRevision = $this->isSubmodule.'/.revision'; @@ -259,34 +260,35 @@ class PHPloy $this->output('Fresh deployment - grab a ☕'); } - $gitCommand = 'git --git-dir="'.$this->repo.'/.git" --work-tree="'.$this->repo.'"'; + $gitCommand = 'git --git-dir="'.$this->repo.'/.git" --work-tree="'.$this->repo.'"'; - if ($localRevision == 'HEAD') { + if (empty($remoteRevision)) { + $command = $gitCommand.' ls-files'; + } else if ($localRevision == 'HEAD') { $command = $gitCommand.' diff --name-status '.$remoteRevision.'...'.$localRevision; } else { - // Swap revisions when you revert $command = $gitCommand.' diff --name-status '.$remoteRevision.'... '.$localRevision; } - $output = array(); exec(escapeshellcmd($command), $output); - $filesToUpload = array(); - $filesToDelete = array(); - - foreach ($output as $line) { - if ($line[0] == 'A' or $line[0] == 'C' or $line[0] == 'M') { - // Added (A), Modified (C), Unmerged (M) - $filesToUpload[] = trim(substr($line, 1)); - } elseif ($line[0] == 'D') { - // Deleted (D) - $filesToDelete[] = trim(substr($line, 1)); - } else { - throw new Exception("Unknown git-diff status: {$line[0]}"); - } - } + if (!empty($remoteRevision)) { + foreach ($output as $line) { + if ($line[0] == 'A' or $line[0] == 'C' or $line[0] == 'M') { + // Added (A), Modified (C), Unmerged (M) + $filesToUpload[] = trim(substr($line, 1)); + } elseif ($line[0] == 'D') { + // Deleted (D) + $filesToDelete[] = trim(substr($line, 1)); + } else { + throw new Exception("Unknown git-diff status: {$line[0]}"); + } + } + } else { + $filesToUpload = $output; + } - $filesToUpload = array_diff($filesToUpload, $this->files_to_ignore); + $filesToUpload = array_diff($filesToUpload, $this->filesToIgnore); return array( 'upload' => $filesToUpload,