Browse Source

Add hostname to the OAuth app name

Jordi Boggiano 12 years ago
parent
commit
32282e7461
1 changed files with 11 additions and 1 deletions
  1. 11 1
      src/Composer/Repository/Vcs/GitHubDriver.php

+ 11 - 1
src/Composer/Repository/Vcs/GitHubDriver.php

@@ -355,11 +355,21 @@ class GitHubDriver extends VcsDriver
                 $password = $this->io->askAndHideAnswer('Password: ');
                 $this->io->setAuthorization($this->originUrl, $username, $password);
 
+                // build up OAuth app name
+                $appName = 'Composer';
+                if (0 === $this->process->execute('hostname', $output)) {
+                    $appName .= ' on ' . trim($output);
+                }
+
                 $contents = JsonFile::parseJson($this->remoteFilesystem->getContents($this->originUrl, 'https://api.github.com/authorizations', false, array(
                     'http' => array(
                         'method' => 'POST',
                         'header' => "Content-Type: application/json\r\n",
-                        'content' => '{"scopes":["repo"],"note":"Composer","note_url":"https://getcomposer.org/"}',
+                        'content' => json_encode(array(
+                            'scopes' => array('repo'),
+                            'note' => $appName,
+                            'note_url' => 'https://getcomposer.org/',
+                        )),
                     )
                 )));
             } catch (TransportException $e) {