Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use getPrettyName; cater for legacy incorrect package names. #50

Merged
merged 6 commits into from
Nov 11, 2017

Conversation

gitlost
Copy link
Contributor

@gitlost gitlost commented Nov 7, 2017

Closes #43
Partially reverts #49

(TLDR: Alas #49 had a number of issues. This PR tries to deal with them and also cater for legacy incorrect names in composer.json.)

Uses Package::getPrettyName() instead of Package::getName() throughout Package_Command (except where needed for legacy situations), as getPrettyName() is the actual case-sensitive name that appears in composer.json.

Allows and corrects for legacy incorrect names being in composer.json, which cause strange behaviour if present. A warning is printed on detection.

Fixes a case-sensitivity bug in Composer\Json\JsonManipulator re package names, which causes mixed-case package names in require and repositories to be left in composer.json, by adding a caseInsensitive arg to addLink(), addSubNode() and removeSubNode(). This required a full copy of Composer\Json\JsonManipulator (due to its use of private member variables) with adaptations.

Reverts the addition in #49 of an outwardly visible pretty_name, as having two names only confuses things and there really can't be BC issues as always outputting lowercase name is wrong. For BC with package-command 1.0.8, still sets pretty_name so it won't fail if specified.

Moves the mismatch code to its own function so it can be called to deal with the shortened form of git url also. Adds some error handling and expands the mismatch message with explicit before and after names.

Also copies the phpunit test for JsonManipulator from Composer, with some additions.

@gitlost gitlost added this to the 1.0.9 milestone Nov 7, 2017
@gitlost
Copy link
Contributor Author

gitlost commented Nov 8, 2017

Re build fail there seems to be issues with github.com at the mo (although the status isn't showing anything yet), or it could be that the GITHUB_TOKEN stuff #47 needs further work...

@danielbachhuber
Copy link
Member

Restarted build

@gitlost
Copy link
Contributor Author

gitlost commented Nov 8, 2017

Failed again so github.com issues can be ruled out I think and it's some issue with the GITHUB_TOKEN/COMPOSER_AUTH stuff added in #47 not working fully.

@danielbachhuber
Copy link
Member

@gitlost Yes, but not in the way you think:

image

@gitlost
Copy link
Contributor Author

gitlost commented Nov 8, 2017

Ha excellent!

@gitlost
Copy link
Contributor Author

gitlost commented Nov 8, 2017

Hmm, can't think of a way around it, which is sad as it's a key test for this PR. What would you think of adding a @local-only tag or similar to ci/behat-tags.php eg

if ( getenv( 'TRAVIS' ) ) {
	$skip_tags[] = '@local-only';
}

@gitlost
Copy link
Contributor Author

gitlost commented Nov 8, 2017

Ah it would fail randomly locally too - will just remove it...

@danielbachhuber
Copy link
Member

What would you think of adding a @local-only tag or similar to ci/behat-tags.php eg

I'm not opposed and don't have a better suggestion, if you think this is the best path forward.

However, I'm not sure of the utility of an integration test that never runs in the CI environment.

@gitlost gitlost requested a review from a team November 8, 2017 16:13
@danielbachhuber
Copy link
Member

Requested a review from @schlessera because I'd like his eyes on it specifically.

*/
private function check_git_package_name( $package_name ) {
// Generate raw git URL of composer.json file.
$raw_content_url = 'https://raw.githubusercontent.com/' . $package_name . '/master/composer.json';
Copy link
Member

Choose a reason for hiding this comment

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

I think we still have a problem here.
The branch master is hardcoded, so the code will pull in the wrong composer.json file if a different branch was requested.
Not a bug with this PR, but rather a bug we already had in the previous iteration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah right so check_git_package_name() needs to take a $version arg as well - should this be a new issue/PR or deal with it here?

Copy link
Member

Choose a reason for hiding this comment

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

I'd say a new PR, as the bug is already in there. This way, we can concentrate on the issue at hand first, and deal with the other bug separately.

Copy link
Member

Choose a reason for hiding this comment

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

I'll merge this one and create a new issue for that bug.

Copy link
Member

Choose a reason for hiding this comment

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

See #51

@schlessera schlessera merged commit 8ac1e64 into master Nov 11, 2017
@schlessera schlessera deleted the legacy_wrong_name branch November 11, 2017 08:24
schlessera added a commit that referenced this pull request Jan 5, 2022
Use getPrettyName; cater for legacy incorrect package names.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants