Просмотр исходного кода

Adjusted config name to be more descriptive, added documentation

Kath Young 6 лет назад
Родитель
Сommit
fbb9d20c33

+ 8 - 0
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,

+ 4 - 0
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\"."

+ 1 - 1
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);

+ 2 - 2
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])) {

+ 1 - 1
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;