Skip to content

Avoid remove author name #444

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

Conversation

HugoSantiagoBecerraAdan

Fixes part of #440

@nicolas-grekas
Copy link
Member

Did you check #441? Can you explain what this changes? I don't get it by reading the code.

@HugoSantiagoBecerraAdan
Copy link
Author

Search for "name" and "description" just once each.

It does not continue searching for more matches of the same word if it is already found, to be sure only the root name is removed and keep the name on the author section.

Already check #441 and I'm trying to solve comment #440 (comment)

@hectorprats
Copy link

hectorprats commented Dec 10, 2018

I think this is still not a complete solution. You should not delete name / description in any case that is not a skeleton. But if you are going to do something like that, better to do:

$manipulator->removeMainKey('name');
$manipulator->removeMainKey('description');
file_put_contents($json->getPath(), $manipulator->getContents());

instead of doing a regexp

@HugoSantiagoBecerraAdan
Copy link
Author

HugoSantiagoBecerraAdan commented Dec 10, 2018

@hectorprats It's not a complete solution but a partial solution just for #440 (comment)

In src/Flex.php line 264 there's a comment that says:
// don't use $manipulator->removeProperty() for BC with Composer 1.0

I guess also applys to $manipulator->removeMainKey().

@hectorprats
Copy link

Ok, @HugoSantiagoBecerraAdan . But your solution does not solve the problem if there is no 'name' key and yes a subkey inside authors.

If I do a create-project to make a git clone & composer install, it can not erase things from the composer.json

In a skeleton it makes sense. But never in other cases.

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

LGTM thanks.
If a composer.json doesn't have a name / description, that's a bug in this file IMHO.

@stof
Copy link
Member

stof commented Dec 11, 2018

A solution could be to use the manipulator if possible, and use the regex only as a fallback for older composer versions.

@nicolas-grekas
Copy link
Member

There is no need to look for a solution when there is no problem ;)
Let's keep the code simple.

@nicolas-grekas nicolas-grekas force-pushed the hotfix/avoid-remove-author-names branch from dc8a059 to cd04581 Compare December 11, 2018 13:58
@nicolas-grekas
Copy link
Member

Thank you @HugoSantiagoBecerraAdan.

@nicolas-grekas nicolas-grekas merged commit cd04581 into symfony:master Dec 11, 2018
nicolas-grekas added a commit that referenced this pull request Dec 11, 2018
This PR was merged into the 1.1-dev branch.

Discussion
----------

Avoid remove author name

Fixes part of #440

Commits
-------

cd04581 Avoid remove author name
@hectorprats
Copy link

hectorprats commented Dec 11, 2018

@nicolas-grekas It's one thing to keep the code simple, and another to do ugly things.

The system of using a regexp to cancel 2 keys of a json is very very ugly. And in the end composer is full of ugly things. For example (although this is another topic), there are dozens of 'if' where you check 2 terms and first check the slow and then the fast.

Or like the other day. Everywhere in the code the labels are closed with </ info>, and if I make a PR to homogenize and remove the </>, someone prefers to leave the 2 forms.

Simple code? Use the methods created for it, and if they are not compatible with something, make that method compatible.

@nicolas-grekas
Copy link
Member

@hectorprats thanks for the opinion. Looking forward to your PR since you seem to care.

@HugoSantiagoBecerraAdan HugoSantiagoBecerraAdan deleted the hotfix/avoid-remove-author-names branch December 12, 2018 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants