Skip to content
This repository has been archived by the owner on Mar 15, 2020. It is now read-only.

Manifest file strategy #15

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

pjcdawkins
Copy link

As described in #13

Minor todos, not sure if you'd want them:

  • add setter methods to match current strategies a bit more closely
  • what about all the copyright/authorship stuff in the file docblock

@padraic
Copy link
Collaborator

padraic commented Jan 5, 2016

@pjcdawkins Thanks for the PR! I'll review over the next week time allowing.

On your two questions:

  1. I'd keep setter names as consistent as possible with existing API (where it makes sense).
  2. Best practice is to include the license block at file head. Also, by all means include your name for author and copyright credit. I do not require copyright assignment, only a compatible license. If the code includes any pre-existing code, do include a line indicating the original source, author and copyright to ensure we abide by the terms of any prevailing license it may fall under, e.g. "Adapted from xxx ". It will also let me double check we're legal ;).

@aik099
Copy link
Contributor

aik099 commented May 31, 2016

Apparently the review stage took longer than expected.

@pjcdawkins
Copy link
Author

pjcdawkins commented May 31, 2016

Ah yes... I also have extended this a bit where I'm using it (in the Platform.sh CLI), to add support for timeouts, for upgrade notes, and for PHP version requirements:
https://github.com/platformsh/platformsh-cli/blob/development/src/SelfUpdate/ManifestStrategy.php

I'll roll that into an update for this PR, if there is still interest.

@ArnaudLigny
Copy link

I'll roll that into an update for this PR, if there is still interest.

👍

@padraic
Copy link
Collaborator

padraic commented Apr 14, 2017

Sorry for the delay folks - my review times suck recently 😁 We'll work around to this much faster this time.

Copy link
Member

@theofidry theofidry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not very familiar with the codebase yet so the technical review is somewhat lacking, but you'll find some comments still :)

use Humbug\SelfUpdate\Updater;
use Humbug\SelfUpdate\VersionParser;

class ManifestStrategy implements StrategyInterface
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would make this class final

private $allowUnstable = false;

/**
* ManifestStrategy constructor.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm personally not very found of noisy comments (i.e. comment not providing any value), so I would remove that line unless @padraic prefer to keep it for consistency. Although I would argue in favour of changing that practice and fixing that inconsistency later :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opinions can vary, but I'm fairly verbose myself in comments. I just find it a PITA, esp. in open source projects, to spend too time familiarising myself with how something works so a bit of hand holding can be welcome.

Also, easy to copy/paste to a README and THEN delete the comments ;).

private $localVersion;
/** @var bool */
private $allowMajor = false;
/** @var bool */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's keep it like:


/**
 * @var bool
 */
private $allowUnstable = false;

if ($version === false) {
throw new \RuntimeException('No remote versions found');
}
$versionInfo = $this->getAvailableVersions();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing blank line between L63-L64

}

/**
* Get available versions to update to.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gets


class UpdaterManifestStrategyTest extends \PHPUnit_Framework_TestCase
{

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary blank line

throw new \RuntimeException(sprintf('Failed to download manifest: %s', $this->manifestUrl));
}

$this->manifest = (array) json_decode($manifestContents, true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$this->manifest = json_decode($manifestContents, true, 512, JSON_OBJECT_AS_ARRAY);

}
}

return $this->manifest;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather return a $manifest property and do $this->manifest = $this->retrieveManifest()

class UpdaterManifestStrategyTest extends \PHPUnit_Framework_TestCase
{

private $files;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing phpdoc for the props

chdir($cwd);
}

public function teardown()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move it just under setUp(), they go together :)

and also there's a missing @inheritdoc for both setUp() and tearDown()

@padraic
Copy link
Collaborator

padraic commented May 12, 2017

Note: Will complete a refresh PR over the weekend - we don't have write access back to the originating branch so will be a basic merge, resolve review pts, and check the additional work noted in comments.

@padraic padraic mentioned this pull request May 13, 2017
8 tasks
@padraic
Copy link
Collaborator

padraic commented May 14, 2017

@pjcdawkins I've updated this PR in #37 and it should be compatible with your final version. The API has been altered to prefer setters, and SHA1 has been moved to an optional downgrade from a SHA-256 default, but otherwise the overall internals are unchanged. If/When #37 is merged, this PR will be closed. Thanks again for opening this PR!

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

Successfully merging this pull request may close these issues.

5 participants