From 2b7b6058399907ec5e65911f03eae5e359695e0f Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 3 Dec 2014 13:06:24 +0000 Subject: [PATCH] Skip empty time values --- src/Composer/Repository/Vcs/GitBitbucketDriver.php | 2 +- src/Composer/Repository/Vcs/GitDriver.php | 2 +- src/Composer/Repository/Vcs/GitHubDriver.php | 2 +- src/Composer/Repository/Vcs/HgBitbucketDriver.php | 2 +- src/Composer/Repository/Vcs/HgDriver.php | 2 +- src/Composer/Repository/Vcs/SvnDriver.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Composer/Repository/Vcs/GitBitbucketDriver.php b/src/Composer/Repository/Vcs/GitBitbucketDriver.php index 12eba6d3a..88a6d5454 100644 --- a/src/Composer/Repository/Vcs/GitBitbucketDriver.php +++ b/src/Composer/Repository/Vcs/GitBitbucketDriver.php @@ -93,7 +93,7 @@ class GitBitbucketDriver extends VcsDriver implements VcsDriverInterface $composer = JsonFile::parseJson($composer, $resource); - if (!isset($composer['time'])) { + if (empty($composer['time'])) { $resource = $this->getScheme() . '://api.bitbucket.org/1.0/repositories/'.$this->owner.'/'.$this->repository.'/changesets/'.$identifier; $changeset = JsonFile::parseJson($this->getContents($resource), $resource); $composer['time'] = $changeset['timestamp']; diff --git a/src/Composer/Repository/Vcs/GitDriver.php b/src/Composer/Repository/Vcs/GitDriver.php index a47643988..50e191c96 100644 --- a/src/Composer/Repository/Vcs/GitDriver.php +++ b/src/Composer/Repository/Vcs/GitDriver.php @@ -156,7 +156,7 @@ class GitDriver extends VcsDriver $composer = JsonFile::parseJson($composer, $resource); - if (!isset($composer['time'])) { + if (empty($composer['time'])) { $this->process->execute(sprintf('git log -1 --format=%%at %s', ProcessExecutor::escape($identifier)), $output, $this->repoDir); $date = new \DateTime('@'.trim($output), new \DateTimeZone('UTC')); $composer['time'] = $date->format('Y-m-d H:i:s'); diff --git a/src/Composer/Repository/Vcs/GitHubDriver.php b/src/Composer/Repository/Vcs/GitHubDriver.php index 06b805714..9dbd21059 100644 --- a/src/Composer/Repository/Vcs/GitHubDriver.php +++ b/src/Composer/Repository/Vcs/GitHubDriver.php @@ -171,7 +171,7 @@ class GitHubDriver extends VcsDriver if ($composer) { $composer = JsonFile::parseJson($composer, $resource); - if (!isset($composer['time'])) { + if (empty($composer['time'])) { $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/commits/'.urlencode($identifier); $commit = JsonFile::parseJson($this->getContents($resource), $resource); $composer['time'] = $commit['commit']['committer']['date']; diff --git a/src/Composer/Repository/Vcs/HgBitbucketDriver.php b/src/Composer/Repository/Vcs/HgBitbucketDriver.php index c6eac73b9..5e6f71241 100644 --- a/src/Composer/Repository/Vcs/HgBitbucketDriver.php +++ b/src/Composer/Repository/Vcs/HgBitbucketDriver.php @@ -102,7 +102,7 @@ class HgBitbucketDriver extends VcsDriver $composer = JsonFile::parseJson($repoData['data'], $resource); - if (!isset($composer['time'])) { + if (empty($composer['time'])) { $resource = $this->getScheme() . '://bitbucket.org/api/1.0/repositories/'.$this->owner.'/'.$this->repository.'/changesets/'.$identifier; $changeset = JsonFile::parseJson($this->getContents($resource), $resource); $composer['time'] = $changeset['timestamp']; diff --git a/src/Composer/Repository/Vcs/HgDriver.php b/src/Composer/Repository/Vcs/HgDriver.php index eb962f276..470651acc 100644 --- a/src/Composer/Repository/Vcs/HgDriver.php +++ b/src/Composer/Repository/Vcs/HgDriver.php @@ -124,7 +124,7 @@ class HgDriver extends VcsDriver $composer = JsonFile::parseJson($composer, $identifier); - if (!isset($composer['time'])) { + if (empty($composer['time'])) { $this->process->execute(sprintf('hg log --template "{date|rfc3339date}" -r %s', ProcessExecutor::escape($identifier)), $output, $this->repoDir); $date = new \DateTime(trim($output), new \DateTimeZone('UTC')); $composer['time'] = $date->format('Y-m-d H:i:s'); diff --git a/src/Composer/Repository/Vcs/SvnDriver.php b/src/Composer/Repository/Vcs/SvnDriver.php index c8d9a17a6..c602ddaa3 100644 --- a/src/Composer/Repository/Vcs/SvnDriver.php +++ b/src/Composer/Repository/Vcs/SvnDriver.php @@ -148,7 +148,7 @@ class SvnDriver extends VcsDriver $composer = JsonFile::parseJson($output, $this->baseUrl . $resource . $rev); - if (!isset($composer['time'])) { + if (empty($composer['time'])) { $output = $this->execute('svn info', $this->baseUrl . $path . $rev); foreach ($this->process->splitLines($output) as $line) { if ($line && preg_match('{^Last Changed Date: ([^(]+)}', $line, $match)) {