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

Support package names that differ from repository names #31

Merged
merged 6 commits into from Oct 2, 2017

Conversation

3 participants
@Sidsector9
Member

Sidsector9 commented Aug 30, 2017

As of now, only packages hosted on GitHub is supported.

Related to issue 4232

@Sidsector9 Sidsector9 requested a review from schlessera Aug 30, 2017

@danielbachhuber

Can you include a test for this change, please? Generally, tests are required for all pull requests.

@Sidsector9

This comment has been minimized.

Show comment
Hide comment
@Sidsector9

Sidsector9 Aug 31, 2017

Member

@danielbachhuber I wanted to discuss this feature before adding tests, as you can see this fix only works for packages hosted on GitHub which restricts Git URLs hosted on different remote repositories like Bitbucket and GitLab. Do you have a better idea which I could implement?

Member

Sidsector9 commented Aug 31, 2017

@danielbachhuber I wanted to discuss this feature before adding tests, as you can see this fix only works for packages hosted on GitHub which restricts Git URLs hosted on different remote repositories like Bitbucket and GitLab. Do you have a better idea which I could implement?

@danielbachhuber

This comment has been minimized.

Show comment
Hide comment
@danielbachhuber
Member

danielbachhuber commented Aug 31, 2017

I'll defer to @schlessera

@schlessera

This comment has been minimized.

Show comment
Hide comment
@schlessera

schlessera Sep 1, 2017

Member

@Sidsector9 There's already a function to get the package name: self::get_package_name_and_version_from_dir_package()
I'm not sure it makes sense to request the composer.json file twice, as in general, names should match up. The check should be done after the package has been normally loaded.
Also, I think the actual action to take when we detect a mismatch should be to fix it automatically, with a warning. To fix it automatically, the "repositories" entry that was created needs to be adapted, to match the correct package name (instead of the GitHub repo name).
Would you be willing to investigate that approach, of fixing the actual problem?

Member

schlessera commented Sep 1, 2017

@Sidsector9 There's already a function to get the package name: self::get_package_name_and_version_from_dir_package()
I'm not sure it makes sense to request the composer.json file twice, as in general, names should match up. The check should be done after the package has been normally loaded.
Also, I think the actual action to take when we detect a mismatch should be to fix it automatically, with a warning. To fix it automatically, the "repositories" entry that was created needs to be adapted, to match the correct package name (instead of the GitHub repo name).
Would you be willing to investigate that approach, of fixing the actual problem?

Sidsector9 added some commits Sep 6, 2017

GH#4232 Fic mapping in composer.json
Repositories map package name to the repository location and require refers to package name.
@Sidsector9

This comment has been minimized.

Show comment
Hide comment
@Sidsector9

Sidsector9 Sep 6, 2017

Member

What's done until now:

  1. Extract username/repository_name from the URL
  2. Obtain package_name from composer.json file using raw GitHub URL
  3. If this package_name is identical to the username/repository_name, then go with the normal flow, if not, then instead of username/repository_name, require will now refer to package_name and inside repositories, package_name will map to the repository URL.

.wp-cli/packages/composer.json will have a structure as

{
    "require": {
        "package_name": "dev-master"
    },
    "repositories": {
        "package_name": {
            "type": "vcs",
            "url": "github.com:user/repository_name.git"
        }
    }
}
Member

Sidsector9 commented Sep 6, 2017

What's done until now:

  1. Extract username/repository_name from the URL
  2. Obtain package_name from composer.json file using raw GitHub URL
  3. If this package_name is identical to the username/repository_name, then go with the normal flow, if not, then instead of username/repository_name, require will now refer to package_name and inside repositories, package_name will map to the repository URL.

.wp-cli/packages/composer.json will have a structure as

{
    "require": {
        "package_name": "dev-master"
    },
    "repositories": {
        "package_name": {
            "type": "vcs",
            "url": "github.com:user/repository_name.git"
        }
    }
}
@schlessera

This comment has been minimized.

Show comment
Hide comment
@schlessera

schlessera Sep 29, 2017

Member

We need to add a test command that include the above problem to the wp-cli-test org and reference that package inside of the feature test instead. I'll create a package now.

Member

schlessera commented Sep 29, 2017

We need to add a test command that include the above problem to the wp-cli-test org and reference that package inside of the feature test instead. I'll create a package now.

@danielbachhuber

This comment has been minimized.

Show comment
Hide comment
@danielbachhuber

danielbachhuber Oct 1, 2017

Member

@schlessera @Sidsector9 Should this land in the next release, or does it need more work?

Member

danielbachhuber commented Oct 1, 2017

@schlessera @Sidsector9 Should this land in the next release, or does it need more work?

@Sidsector9

This comment has been minimized.

Show comment
Hide comment
@Sidsector9

Sidsector9 Oct 1, 2017

Member

@danielbachhuber This is ready.

Member

Sidsector9 commented Oct 1, 2017

@danielbachhuber This is ready.

@schlessera schlessera added this to the 1.0.5 milestone Oct 2, 2017

Required test was added.

@schlessera schlessera merged commit 49f394e into wp-cli:master Oct 2, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@schlessera schlessera changed the title from GH#4232 Added check for package name to Support package names that differ from repository names Oct 2, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment