From 3d1e0e79ccc79af687beaf807123496fa74053d3 Mon Sep 17 00:00:00 2001 From: Kath Young Date: Tue, 22 Jan 2019 11:18:35 +1030 Subject: [PATCH 1/4] Allow for no-api for Github to be a composer configuration as well as repo specific --- src/Composer/Config.php | 5 +++-- src/Composer/Repository/Vcs/GitHubDriver.php | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Composer/Config.php b/src/Composer/Config.php index 7b4220724..c34d8f38f 100644 --- a/src/Composer/Config.php +++ b/src/Composer/Config.php @@ -61,6 +61,7 @@ class Config 'archive-format' => 'tar', 'archive-dir' => '.', 'htaccess-protect' => true, + 'no-api' => false, // valid keys without defaults (auth config stuff): // bitbucket-oauth // github-oauth @@ -317,10 +318,10 @@ class Config case 'disable-tls': return $this->config[$key] !== 'false' && (bool) $this->config[$key]; - case 'secure-http': return $this->config[$key] !== 'false' && (bool) $this->config[$key]; - + case 'no-api': + return $this->config[$key] !== 'false' && (bool) $this->config[$key]; default: if (!isset($this->config[$key])) { return null; diff --git a/src/Composer/Repository/Vcs/GitHubDriver.php b/src/Composer/Repository/Vcs/GitHubDriver.php index d0b721af9..14e51699f 100644 --- a/src/Composer/Repository/Vcs/GitHubDriver.php +++ b/src/Composer/Repository/Vcs/GitHubDriver.php @@ -56,7 +56,7 @@ class GitHubDriver extends VcsDriver } $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.$this->originUrl.'/'.$this->owner.'/'.$this->repository); - if (isset($this->repoConfig['no-api']) && $this->repoConfig['no-api']) { + if ( $this->config->get('no-api') === true || (isset($this->repoConfig['no-api']) && $this->repoConfig['no-api'] ) ){ $this->setupGitDriver($this->url); return; From 8b1f8a46293669ac9b5b0737bd4715108b3245c6 Mon Sep 17 00:00:00 2001 From: Kath Young Date: Tue, 22 Jan 2019 11:22:55 +1030 Subject: [PATCH 2/4] Add no-api in the config as an acceptable config --- src/Composer/Command/ConfigCommand.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Composer/Command/ConfigCommand.php b/src/Composer/Command/ConfigCommand.php index b002fd3a7..3ed62e0c5 100644 --- a/src/Composer/Command/ConfigCommand.php +++ b/src/Composer/Command/ConfigCommand.php @@ -302,6 +302,7 @@ EOT $uniqueConfigValues = array( 'process-timeout' => array('is_numeric', 'intval'), 'use-include-path' => array($booleanValidator, $booleanNormalizer), + 'no-api' => array($booleanValidator, $booleanNormalizer), 'preferred-install' => array( function ($val) { return in_array($val, array('auto', 'source', 'dist'), true); From fbb9d20c33597b2aeb1d985e2d44ff8cb00e9c62 Mon Sep 17 00:00:00 2001 From: Kath Young Date: Tue, 29 Jan 2019 07:23:24 +1030 Subject: [PATCH 3/4] Adjusted config name to be more descriptive, added documentation --- doc/06-config.md | 8 ++++++++ res/composer-schema.json | 4 ++++ src/Composer/Command/ConfigCommand.php | 2 +- src/Composer/Config.php | 4 ++-- src/Composer/Repository/Vcs/GitHubDriver.php | 2 +- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/doc/06-config.md b/doc/06-config.md index 87ffb02a0..6fc743f13 100644 --- a/doc/06-config.md +++ b/doc/06-config.md @@ -234,6 +234,14 @@ github API will have a date instead of the machine hostname. Defaults to `["gitlab.com"]`. A list of domains of GitLab servers. This is used if you use the `gitlab` repository type. +## use-github-api + +Defaults to `true`. Similar to the `no-api` key on a specific repository, setting `use-github-api` to `false` will define the global behavior for all GitHub repositories to clone the +repository as it would with any other git repository instead of using the +GitHub API. But unlike using the `git` driver directly, Composer will still +attempt to use github's zip files. + + ## notify-on-install Defaults to `true`. Composer allows repositories to define a notification URL, diff --git a/res/composer-schema.json b/res/composer-schema.json index ce80c209b..cb3594f7b 100644 --- a/res/composer-schema.json +++ b/res/composer-schema.json @@ -271,6 +271,10 @@ "type": "string" } }, + "use-github-api": { + "type": "boolean", + "description": "Defaults to true. If set to false, globally disables the use of the GitHub API for all GitHub repositories and clones the repository as it would for any other repository." + }, "archive-format": { "type": "string", "description": "The default archiving format when not provided on cli, defaults to \"tar\"." diff --git a/src/Composer/Command/ConfigCommand.php b/src/Composer/Command/ConfigCommand.php index 3ed62e0c5..d6fe2844f 100644 --- a/src/Composer/Command/ConfigCommand.php +++ b/src/Composer/Command/ConfigCommand.php @@ -302,7 +302,7 @@ EOT $uniqueConfigValues = array( 'process-timeout' => array('is_numeric', 'intval'), 'use-include-path' => array($booleanValidator, $booleanNormalizer), - 'no-api' => array($booleanValidator, $booleanNormalizer), + 'use-github-api' => array($booleanValidator, $booleanNormalizer), 'preferred-install' => array( function ($val) { return in_array($val, array('auto', 'source', 'dist'), true); diff --git a/src/Composer/Config.php b/src/Composer/Config.php index c34d8f38f..941505252 100644 --- a/src/Composer/Config.php +++ b/src/Composer/Config.php @@ -61,7 +61,7 @@ class Config 'archive-format' => 'tar', 'archive-dir' => '.', 'htaccess-protect' => true, - 'no-api' => false, + 'use-github-api' => true, // valid keys without defaults (auth config stuff): // bitbucket-oauth // github-oauth @@ -320,7 +320,7 @@ class Config return $this->config[$key] !== 'false' && (bool) $this->config[$key]; case 'secure-http': return $this->config[$key] !== 'false' && (bool) $this->config[$key]; - case 'no-api': + case 'use-github-api': return $this->config[$key] !== 'false' && (bool) $this->config[$key]; default: if (!isset($this->config[$key])) { diff --git a/src/Composer/Repository/Vcs/GitHubDriver.php b/src/Composer/Repository/Vcs/GitHubDriver.php index 14e51699f..42b30222e 100644 --- a/src/Composer/Repository/Vcs/GitHubDriver.php +++ b/src/Composer/Repository/Vcs/GitHubDriver.php @@ -56,7 +56,7 @@ class GitHubDriver extends VcsDriver } $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.$this->originUrl.'/'.$this->owner.'/'.$this->repository); - if ( $this->config->get('no-api') === true || (isset($this->repoConfig['no-api']) && $this->repoConfig['no-api'] ) ){ + if ( $this->config->get('use-github-api') === false || (isset($this->repoConfig['no-api']) && $this->repoConfig['no-api'] ) ){ $this->setupGitDriver($this->url); return; From 2d7a8c67e88281af1f35fc5766486bbbeb288ca6 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 29 Jan 2019 10:55:05 +0100 Subject: [PATCH 4/4] Doc formatting fixes --- doc/06-config.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/06-config.md b/doc/06-config.md index 6fc743f13..87d73f8a1 100644 --- a/doc/06-config.md +++ b/doc/06-config.md @@ -236,11 +236,11 @@ This is used if you use the `gitlab` repository type. ## use-github-api -Defaults to `true`. Similar to the `no-api` key on a specific repository, setting `use-github-api` to `false` will define the global behavior for all GitHub repositories to clone the -repository as it would with any other git repository instead of using the -GitHub API. But unlike using the `git` driver directly, Composer will still -attempt to use github's zip files. - +Defaults to `true`. Similar to the `no-api` key on a specific repository, +setting `use-github-api` to `false` will define the global behavior for all +GitHub repositories to clone the repository as it would with any other git +repository instead of using the GitHub API. But unlike using the `git` +driver directly, Composer will still attempt to use GitHub's zip files. ## notify-on-install