Skip to content

Commit

Permalink
Merge branch '1.0' into 1
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Apr 9, 2024
2 parents 206ba56 + 16c3a87 commit 04b8661
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,13 @@ This action has no inputs
This action will identify the CMS major version which is determined by parsing the contents on the modules `composer.json` using logic in the `funcs.php` file. In cases where the major version remains indeterminable, the action will fail. This is most likely if the module is not intended as an addon for a website.

To work around this, specify an arbitrary CMS major version by setting the required PHP version in `composer.json` to `^8.1` or any other minimum PHP version that aligns with a CMS major version.

## Preventing merge-ups from specific major versions of a repository

Update `DO_NOT_MERGE_UP_FROM_MAJOR` in `funcs.php`. For example to prevent merging up from the `3` major version of `silverstripe/silverstripe-linkfield`:

```php
const DO_NOT_MERGE_UP_FROM_MAJOR = [
'silverstripe/silverstripe-linkfield' => '3',
];
```
15 changes: 15 additions & 0 deletions funcs.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
// This should always match default branch of silverstripe/framework
const CURRENT_CMS_MAJOR = 5;

// List of major branches to not merge up from
// Add repos in here where the repo was previously unsupported
// Note these are actual major branches, not CMS major versions
const DO_NOT_MERGE_UP_FROM_MAJOR = [
'silverstripe/silverstripe-linkfield' => '3',
];

function branches(
string $defaultBranch,
string $minimumCmsMajor,
Expand Down Expand Up @@ -152,6 +159,14 @@ function branches(
}
$foundMinorInMajor[$major] = true;
}

// remove any branches less than or equal to DO_NOT_MERGE_UP_FROM_MAJOR
if (isset(DO_NOT_MERGE_UP_FROM_MAJOR[$githubRepository])) {
$doNotMergeUpFromMajor = DO_NOT_MERGE_UP_FROM_MAJOR[$githubRepository];
$branches = array_filter($branches, function($branch) use ($doNotMergeUpFromMajor) {
return version_compare($branch, $doNotMergeUpFromMajor, '>');
});
}

// reverse the array so that oldest is first
$branches = array_reverse($branches);
Expand Down
61 changes: 61 additions & 0 deletions tests/BranchesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,67 @@ public function provideBranches()
]
EOT,
],
'silverstripe-linkfield beta' => [
'expected' => ['4.0', '4', '5'],
'defaultBranch' => '4',
'minimumCmsMajor' => '4',
'githubRepository' => 'silverstripe/silverstripe-linkfield',
'composerJson' => <<<EOT
{
"require": {
"silverstripe/framework": "^5"
}
}
EOT,
'branchesJson' => <<<EOT
[
{"name": "1"},
{"name": "2"},
{"name": "3"},
{"name": "4"},
{"name": "4.0"},
{"name": "5"}
]
EOT,
'tagsJson' => <<<EOT
[
{"name": "3.0.0-beta1"},
{"name": "2.0.0"},
{"name": "1.0.0"}
]
EOT,
],
'silverstripe-linkfield stable' => [
'expected' => ['4.0', '4', '5'],
'defaultBranch' => '4',
'minimumCmsMajor' => '4',
'githubRepository' => 'silverstripe/silverstripe-linkfield',
'composerJson' => <<<EOT
{
"require": {
"silverstripe/framework": "^5"
}
}
EOT,
'branchesJson' => <<<EOT
[
{"name": "1"},
{"name": "2"},
{"name": "3"},
{"name": "4"},
{"name": "4.0"},
{"name": "5"}
]
EOT,
'tagsJson' => <<<EOT
[
{"name": "4.0.0"},
{"name": "3.0.0"},
{"name": "2.0.0"},
{"name": "1.0.0"}
]
EOT,
],
];
}
}

0 comments on commit 04b8661

Please sign in to comment.