Skip to content

Commit

Permalink
Merge pull request #242 from creative-commoners/pulls/master/only-cha…
Browse files Browse the repository at this point in the history
…nge-recipe-constraints

FIX Only change constraints for recipes
  • Loading branch information
GuySartorelli committed Mar 28, 2023
2 parents 3bafe3e + 1f1cdb7 commit d87063a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
13 changes: 13 additions & 0 deletions src/Model/Modules/Library.php
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,19 @@ public function getName()
return $data['name'];
}

/**
* Get type of this library
*/
public function getType(): string
{
$data = $this->getComposerData();
return $data['type'] ?? '';
}

public function isRecipe(): bool
{
return $this->getType() === 'silverstripe-recipe';
}

/**
* Get link to github module
Expand Down
4 changes: 3 additions & 1 deletion src/Steps/Release/MergeUpRelease.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ protected function mergeUp(
}

// Step 3. Convert constraints to the appropriate dev format
ConstraintStabiliser::destabiliseConstraints($output, $releasePlanNode, $isMajorBranch);
if ($library->isRecipe()) {
ConstraintStabiliser::destabiliseConstraints($output, $releasePlanNode, $isMajorBranch);
}

// Step 4. Push branch
if ($pushToRemote) {
Expand Down
8 changes: 6 additions & 2 deletions src/Steps/Release/PublishRelease.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,17 @@ protected function releaseLibrary(OutputInterface $output, LibraryRelease $relea
$this->log($output, "Releasing library <info>{$name}</info> at version <info>{$versionName}</info>");

// Step 1: Rewrite composer.json to all tagged versions only
ConstraintStabiliser::stabiliseConstraints($output, $releasePlanNode);
if ($library->isRecipe()) {
ConstraintStabiliser::stabiliseConstraints($output, $releasePlanNode);
}

// Step 2: Tag and push this tag
$this->publishTag($output, $releasePlanNode);

// Step 3: Rewrite composer.json to destabilise requirements
ConstraintStabiliser::destabiliseConstraints($output, $releasePlanNode, false);
if ($library->isRecipe()) {
ConstraintStabiliser::destabiliseConstraints($output, $releasePlanNode, false);
}

// Step 4: Push development branch to origin
$this->log($output, "Pushing branch <info>{$branch}</info>");
Expand Down
9 changes: 5 additions & 4 deletions src/Steps/Release/RewriteReleaseBranches.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@ protected function recursiveBranchLibrary(OutputInterface $output, LibraryReleas
$this->checkoutLibrary($output, $libraryRelease->getLibrary(), $libraryRelease->getVersion());
}

// Ensure any newly created branches have the correct 4.12.x-dev contraints
// need to do this because new branches would have been branched from
// recipes with 4.x-dev contraints
ConstraintStabiliser::destabiliseConstraints($output, $libraryRelease, false);
// Ensure any newly created branches on recipes have the correct 4.12.x-dev contraint format.
// Need to do this because new branches would have been branched from recipes with 4.x-dev contraint format.
if ($libraryRelease->getLibrary()->isRecipe()) {
ConstraintStabiliser::destabiliseConstraints($output, $libraryRelease, false);
}
}

/**
Expand Down

0 comments on commit d87063a

Please sign in to comment.