Skip to content

Commit 10295aa

Browse files
authored
Merge pull request #33 from packagist/t/packages-repo-type
Packages: add option to force the repo type
2 parents 11a8755 + 2a32592 commit 10295aa

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,12 @@ $job = $client->packages()->createVcsPackage('https://github.com/acme-website/pa
405405
```
406406
Returns a new job.
407407

408+
##### Create a vcs package with a specific type
409+
```php
410+
$job = $client->packages()->createVcsPackage('https://github.com/acme-website/package', null, 'git');
411+
```
412+
Returns a new job.
413+
408414
##### Create a custom package
409415
```php
410416
$packageDefinition = '{...}';

src/Api/Packages.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ public function show($packageName)
5454
return $this->get(sprintf('/packages/%s/', $packageName));
5555
}
5656

57-
public function createVcsPackage($url, $credentialId = null)
57+
public function createVcsPackage($url, $credentialId = null, $type = 'vcs')
5858
{
59-
return $this->post('/packages/', ['repoType' => 'vcs', 'repoUrl' => $url, 'credentials' => $credentialId]);
59+
return $this->post('/packages/', ['repoType' => $type, 'repoUrl' => $url, 'credentials' => $credentialId]);
6060
}
6161

6262
public function createCustomPackage($customJson, $credentialId = null)
@@ -76,9 +76,9 @@ public function updateVcsPackage($packageName, $url, $credentialId = null)
7676
return $this->editVcsPackage($packageName, $url, $credentialId);
7777
}
7878

79-
public function editVcsPackage($packageName, $url, $credentialId = null)
79+
public function editVcsPackage($packageName, $url, $credentialId = null, $type = 'vcs')
8080
{
81-
return $this->put(sprintf('/packages/%s/', $packageName), ['repoType' => 'vcs', 'repoUrl' => $url, 'credentials' => $credentialId]);
81+
return $this->put(sprintf('/packages/%s/', $packageName), ['repoType' => $type, 'repoUrl' => $url, 'credentials' => $credentialId]);
8282
}
8383

8484
/**

src/Api/Subrepositories/Packages.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ public function show($subrepositoryName, $packageName)
2828
return $this->get(sprintf('/subrepositories/%s/packages/%s', $subrepositoryName, $packageName));
2929
}
3030

31-
public function createVcsPackage($subrepositoryName, $url, $credentialId = null)
31+
public function createVcsPackage($subrepositoryName, $url, $credentialId = null, $type = 'vcs')
3232
{
33-
return $this->post(sprintf('/subrepositories/%s/packages/', $subrepositoryName), ['repoType' => 'vcs', 'repoUrl' => $url, 'credentials' => $credentialId]);
33+
return $this->post(sprintf('/subrepositories/%s/packages/', $subrepositoryName), ['repoType' => $type, 'repoUrl' => $url, 'credentials' => $credentialId]);
3434
}
3535

3636
public function createCustomPackage($subrepositoryName, $customJson, $credentialId = null)
@@ -42,9 +42,9 @@ public function createCustomPackage($subrepositoryName, $customJson, $credential
4242
return $this->post(sprintf('/subrepositories/%s/packages/', $subrepositoryName), ['repoType' => 'package', 'repoConfig' => $customJson, 'credentials' => $credentialId]);
4343
}
4444

45-
public function editVcsPackage($subrepositoryName, $packageName, $url, $credentialId = null)
45+
public function editVcsPackage($subrepositoryName, $packageName, $url, $credentialId = null, $type = 'vcs')
4646
{
47-
return $this->put(sprintf('/subrepositories/%s/packages/%s/', $subrepositoryName, $packageName), ['repoType' => 'vcs', 'repoUrl' => $url, 'credentials' => $credentialId]);
47+
return $this->put(sprintf('/subrepositories/%s/packages/%s/', $subrepositoryName, $packageName), ['repoType' => $type, 'repoUrl' => $url, 'credentials' => $credentialId]);
4848
}
4949

5050
public function editCustomPackage($subrepositoryName, $packageName, $customJson, $credentialId = null)

0 commit comments

Comments
 (0)