Skip to content

Commit

Permalink
Merge branch 'master' into v2
Browse files Browse the repository at this point in the history
  • Loading branch information
sadortun committed Apr 26, 2020
2 parents 4b9d1a7 + 94e3f87 commit 10ec94b
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 5 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# Repman - PHP Repository Manager

[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%207.4-8892BF.svg)](https://php.net/)
[![Uptime Robot ratio (24h)](https://badgen.net/uptime-robot/day/m784813562-93c7dab381e24ccdb679c5d2)](https://stats.uptimerobot.com/QAMQli6XQM)
[![buddy pipeline](https://app.buddy.works/repman/repman/pipelines/pipeline/244546/badge.svg?token=dbd28b3ece0d16aba095b8a33d0893d15f0403fbcc285a2a1a175cc77f7c94a8 "buddy pipeline")](https://app.buddy.works/repman/repman/pipelines/pipeline/244546)
[![codecov](https://codecov.io/gh/repman-io/repman/branch/master/graph/badge.svg)](https://codecov.io/gh/repman-io/repman)
[![Hits-of-Code](https://hitsofcode.com/github/repman-io/repman)](https://hitsofcode.com/view/github/repman-io/repman)
[![Maintainability](https://api.codeclimate.com/v1/badges/23a93132c8273cabf9eb/maintainability)](https://codeclimate.com/github/repman-io/repman/maintainability)
[![Docker Pulls](https://img.shields.io/docker/pulls/buddy/repman)](https://hub.docker.com/r/buddy/repman)
![License](https://img.shields.io/github/license/repman-io/repman)

**Repman** is a PHP repository manager. Main features:
Expand Down
6 changes: 4 additions & 2 deletions src/Controller/Admin/OrganizationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ public function remove(Organization $organization, Request $request): Response
/**
* @Route("/admin/stats", name="admin_stats", methods={"GET"})
*/
public function stats(): Response
public function stats(Request $request): Response
{
$days = min(max((int) $request->get('days', 30), 7), 365);

return $this->render('admin/stats.html.twig', [
'installs' => $this->organizationQuery->getInstalls(),
'installs' => $this->organizationQuery->getInstalls($days),
]);
}
}
4 changes: 4 additions & 0 deletions src/Service/Dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public function package(): string

public function version(): string
{
if (strpos($this->version, '/') !== false) {
return md5($this->version);
}

return $this->version;
}

Expand Down
3 changes: 1 addition & 2 deletions src/Service/GitLabApi/RestGitLabApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ public function projects(string $accessToken): Projects
);
}, $this->pager->fetchAll($this->client->projects(), 'all', [[
'simple' => true,
'owned' => true,
'membership' => true,
'order_by' => 'path',
'order_by' => 'last_activity_at',
]])));
}

Expand Down
2 changes: 1 addition & 1 deletion src/Service/Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ private function tryToDownload(string $package, string $version, Dist $dist, boo
$providerData = $this->providerData($package, $fromCache ? 0 : -60)->getOrElse([]);
foreach ($providerData['packages'][$package] ?? [] as $packageData) {
$packageVersion = $packageData['version_normalized'] ?? $this->versionParser->normalize($packageData['version']);
if ($packageVersion === $version && isset($packageData['dist']['url'])) {
if (($packageVersion === $version || md5($packageVersion) === $version) && isset($packageData['dist']['url'])) {
$this->distStorage->download($packageData['dist']['url'], $dist);

return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,53 @@
"uid": 3420230,
"notification-url": "https:\/\/packagist.org\/downloads\/"
},
"dev-feature/awesome": {
"name": "buddy-works\/repman",
"description": "Power of object-oriented programming with the elegance of functional programming.",
"keywords": [],
"homepage": "",
"version": "dev-feature/awesome",
"version_normalized": "dev-feature/awesome",
"license": [
"MIT"
],
"authors": [
{
"name": "Arkadiusz Kondas",
"email": "arkadiusz.kondas@gmail.com"
}
],
"source": {
"type": "git",
"url": "https:\/\/github.com\/munusphp\/munus.git",
"reference": "e738ed3634a11f6b5e23aca3d1c3f9be4efd8cfb"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/munusphp\/munus\/zipball\/e738ed3634a11f6b5e23aca3d1c3f9be4efd8cfb",
"reference": "e738ed3634a11f6b5e23aca3d1c3f9be4efd8cfb",
"shasum": ""
},
"type": "library",
"time": "2019-12-08T08:35:40+00:00",
"autoload": {
"psr-4": {
"Munus\\": "src\/"
}
},
"require": {
"php": "^7.2"
},
"require-dev": {
"friendsofphp\/php-cs-fixer": "^2.15",
"phpunit\/phpunit": "^8.4",
"vimeo\/psalm": "^3.6",
"psalm\/plugin-phpunit": "^0.7.0",
"phpstan\/phpstan": "^0.11.19"
},
"uid": 3386500,
"notification-url": "https:\/\/packagist.org\/downloads\/"
},
"dev-master": {
"name": "buddy-works\/repman",
"description": "Power of object-oriented programming with the elegance of functional programming.",
Expand Down
Binary file not shown.
19 changes: 19 additions & 0 deletions tests/Unit/Service/ProxyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,23 @@ public function testStorageNotForceToDownloadWhenDistExists(): void
$proxy->distFilename('buddy-works/repman', '0.1.2.0', 'f0c896a759d4e2e1eff57978318e841911796305', 'zip')->get()
);
}

public function testStorageHandleDistWithSlashInVersion(): void
{
$distFilepath = __DIR__.'/../../Resources/packagist.org/dist/buddy-works/repman/0cdaa0ab95de9fcf94ad9b1d2f80e15d_e738ed3634a11f6b5e23aca3d1c3f9be4efd8cfb.zip';
/** @phpstan-var mixed $storage */
$storage = $this->prophesize(Storage::class);
$storage->has(Argument::type(Dist::class))->willReturn(false);
$storage->filename(Argument::type(Dist::class))->willReturn($distFilepath);
$storage->download('https://api.github.com/repos/munusphp/munus/zipball/e738ed3634a11f6b5e23aca3d1c3f9be4efd8cfb', Argument::type(Dist::class))
->shouldBeCalledOnce();

$proxy = new Proxy('packagist.org', 'https://packagist.org', new CacheableMetadataProvider(new FakeDownloader(), new InMemoryCache()), $storage->reveal());

self::assertStringContainsString(
'0cdaa0ab95de9fcf94ad9b1d2f80e15d_e738ed3634a11f6b5e23aca3d1c3f9be4efd8cfb.zip',
$proxy->distFilename('buddy-works/repman', 'dev-feature/awesome', 'e738ed3634a11f6b5e23aca3d1c3f9be4efd8cfb', 'zip')->get()
);
self::assertEquals('0cdaa0ab95de9fcf94ad9b1d2f80e15d', (new Dist('repo', 'package', 'dev-feature/awesome', 'ref', 'format'))->version());
}
}

0 comments on commit 10ec94b

Please sign in to comment.