Skip to content

Commit f4d23ea

Browse files
feature #648 Support more than just "master" as the default branch (nicolas-grekas)
This PR was merged into the 1.8-dev branch. Discussion ---------- Support more than just "master" as the default branch Commits ------- a9bf093 Support more than just "master" as the default branch
2 parents 319f785 + a9bf093 commit f4d23ea

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

src/Command/RecipesCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ private function displayPackageInformation(Recipe $recipe)
137137
$lockRef = $recipeLock['recipe']['ref'] ?? null;
138138
$lockRepo = $recipeLock['recipe']['repo'] ?? null;
139139
$lockFiles = $recipeLock['files'] ?? null;
140+
$lockBranch = $recipeLock['recipe']['branch'] ?? null;
140141

141142
$status = '<comment>up to date</comment>';
142143
if ($recipe->isAuto()) {
@@ -147,15 +148,14 @@ private function displayPackageInformation(Recipe $recipe)
147148
$status = '<comment>update available</comment>';
148149
}
149150

150-
$branch = $recipeLock['recipe']['branch'] ?? 'master';
151151
$gitSha = null;
152152
$commitDate = null;
153153
if (null !== $lockRef && null !== $lockRepo) {
154154
try {
155155
list($gitSha, $commitDate) = $this->findRecipeCommitDataFromTreeRef(
156156
$recipe->getName(),
157157
$lockRepo,
158-
$branch,
158+
$lockBranch ?? '',
159159
$recipeLock['version'],
160160
$lockRef
161161
);
@@ -172,7 +172,7 @@ private function displayPackageInformation(Recipe $recipe)
172172
'https://%s/tree/%s/%s/%s',
173173
$lockRepo,
174174
// if something fails, default to the branch as the closest "sha"
175-
$gitSha ?? $branch,
175+
$gitSha ?? $lockBranch,
176176
$recipe->getName(),
177177
$recipeLock['version']
178178
);
@@ -186,7 +186,7 @@ private function displayPackageInformation(Recipe $recipe)
186186
$historyUrl = sprintf(
187187
'https://%s/commits/%s/%s',
188188
$lockRepo,
189-
$branch,
189+
$lockBranch,
190190
$recipe->getName()
191191
);
192192

src/Downloader.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,15 @@ public function getRecipes(array $operations): array
110110
$branchAliases = $package->getExtra()['branch-alias'];
111111
if (
112112
(isset($branchAliases[$version]) && $alias = $branchAliases[$version]) ||
113+
(isset($branchAliases['dev-main']) && $alias = $branchAliases['dev-main']) ||
114+
(isset($branchAliases['dev-trunk']) && $alias = $branchAliases['dev-trunk']) ||
115+
(isset($branchAliases['dev-develop']) && $alias = $branchAliases['dev-develop']) ||
116+
(isset($branchAliases['dev-default']) && $alias = $branchAliases['dev-default']) ||
117+
(isset($branchAliases['dev-latest']) && $alias = $branchAliases['dev-latest']) ||
118+
(isset($branchAliases['dev-next']) && $alias = $branchAliases['dev-next']) ||
119+
(isset($branchAliases['dev-current']) && $alias = $branchAliases['dev-current']) ||
120+
(isset($branchAliases['dev-support']) && $alias = $branchAliases['dev-support']) ||
121+
(isset($branchAliases['dev-tip']) && $alias = $branchAliases['dev-tip']) ||
113122
(isset($branchAliases['dev-master']) && $alias = $branchAliases['dev-master'])
114123
) {
115124
$version = $alias;

src/Flex.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ private function getFlexId()
879879

880880
private function formatOrigin(string $origin): string
881881
{
882-
// symfony/translation:[email protected]/symfony/recipes:master
882+
// symfony/translation:[email protected]/symfony/recipes:branch
883883
if (!preg_match('/^([^:]++):([^@]++)@(.+)$/', $origin, $matches)) {
884884
return $origin;
885885
}

src/Recipe.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function getURL(): string
7373
return '';
7474
}
7575

76-
// symfony/translation:[email protected]/symfony/recipes:master
76+
// symfony/translation:[email protected]/symfony/recipes:branch
7777
if (!preg_match('/^([^:]++):([^@]++)@([^:]++):(.+)$/', $this->data['origin'], $matches)) {
7878
// that excludes auto-generated recipes, which is what we want
7979
return '';

0 commit comments

Comments
 (0)