From a31353f46de8daf64df9fded496b0cb775e0bf54 Mon Sep 17 00:00:00 2001 From: Sickenberg Romain Date: Wed, 30 Mar 2022 14:41:03 +0200 Subject: [PATCH 01/13] feat(default_branch): refactored the default branch from master to main DIDN'T RAN PHPUNIT (YET) --- .github/workflows/ci.yml | 2 +- README.md | 38 +++++++++---------- .../templates/default-vcs-config.yml.tmpl | 4 +- test/Liip/RMT/Tests/Functional/GitTest.php | 3 +- .../RMT/Tests/Functional/InitCommandTest.php | 6 +-- test/Liip/RMT/Tests/Unit/VCS/GitTest.php | 10 ++--- 6 files changed, 31 insertions(+), 32 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9e544589..469da6cd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -77,7 +77,7 @@ jobs: run: | git config --global user.email "test@test.com" git config --global user.name "John Doe" - git config --global init.defaultBranch master # TODO: use main, need to adjust tests to match + git config --global init.defaultBranch main - name: Run tests run: phpunit diff --git a/README.md b/README.md index 27520c0c..5288f809 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ RMT - Release Management Tool [![Total Downloads](https://poser.pugx.org/liip/RMT/d/total.png)](https://packagist.org/packages/liip/RMT) [![License](https://poser.pugx.org/liip/rmt/license.svg)](https://packagist.org/packages/liip/rmt) -RMT is a handy tool to help releasing new versions of your software. You can define the type +RMT is a handy tool to help releasing a new versions of your software. You can define the type of version generator you want to use (e.g. semantic versioning), where you want to store the version (e.g. in a changelog file or as a VCS tag) and a list of actions that should be executed before or after the release of a new version. @@ -14,7 +14,7 @@ executed before or after the release of a new version. Installation ------------ ### Option 1: As a development dependency of your project -In order to use RMT in your project you should use [Composer](http://getcomposer.org/) to install it +To use RMT in your project you should use [Composer](http://getcomposer.org/) to install it as a dev-dependency. Just go to your project's root directory and execute: composer require --dev liip/rmt @@ -31,7 +31,7 @@ root folder. You can now start using RMT by executing: Once there, your best option is to pick one of the [configuration examples](#configuration-examples) below and adapt it to your needs. -If you are using a versioning tool, we recommend to add both Composer files (`composer.json` +If you are using a versioning tool, we recommend adding both Composer files (`composer.json` and `composer.lock`), the RMT configuration file(`.rmt.yml`) and the `RMT` executable script to it. The `vendor` directory should be ignored as it is populated when running `composer install`. @@ -62,9 +62,9 @@ directly `./rmt.phar` or run it by invoking it through PHP via `php rmt.phar`. For the usage substitute RMT with whatever variant you have decided to use. ### Option 4: As Drifter role -If your are using https://github.com/liip/drifter for your project, you just need three step +If you are using https://github.com/liip/drifter for your project, you just need three step * Activate the `rmt` role -* Re-run the provisionning `vagrant provision` +* Re-run the provisioning `vagrant provision` * Init RMT for your project `php /home/vagrant/.config/composer/vendor/liip/rmt/RMT` Usage @@ -128,7 +128,7 @@ branch `master`. Example: _default: version-generator: "simple" version-persister: "vcs-tag" - master: + main: pre-release-actions: [changelog-update] You can use the command `RMT config` to see the merge result between _default and your current branch. @@ -138,7 +138,7 @@ You can use the command `RMT config` to see the merge result between _default an Build-in version number generation strategies. * simple: This generator is doing a simple increment (1,2,3...) -* semantic: A generator which implements [Semantic versioning](http://semver.org) +* semantic: A generator, which implements [Semantic versioning](http://semver.org) * Option `allow-label` (boolean): To allow adding a label on a version (such as -beta, -rcXX) (default: *false*) * Option `type`: to force the version type * Option `label`: to force the label @@ -151,8 +151,8 @@ Build-in version number generation strategies. Class in charge of saving/retrieving the version number. * vcs-tag: Save the version as a VCS tag - * Option `tag-pattern`: Allow to provide a regex that all tag must match. This allow for example to release a version 1.X.X in a specific branch and to release a 2.X.X in a separate branch - * Option `tag-prefix`: Allow to prefix all VCS tag with a string. You can have a numeric versionning but generation tags such as `v_2.3.4`. As a bonus you can use a specific placeholder: `{branch-name}` that will automatically inject the current branch name in the tag. So use, simple generation and `tag-prefix: "{branch-name}_"` and it will generate tag like `featureXY_1`, `featureXY_2`, etc... + * Option `tag-pattern`: Allow to provide a regex that all tag must match. This allows for example to release a version 1.X.X in a specific branch and to release a 2.X.X in a separate branch + * Option `tag-prefix`: Allow to prefix all VCS tag with a string. You can have a numeric versioning but generation tags such as `v_2.3.4`. As a bonus you can use a specific placeholder: `{branch-name}` that will automatically inject the current branch name in the tag. So use, simple generation and `tag-prefix: "{branch-name}_"` and it will generate tag like `featureXY_1`, `featureXY_2`, etc... * changelog: Save the version in the changelog file * Option `location`: Changelog file name an location (default: *CHANGELOG*) @@ -166,9 +166,9 @@ Prerequisite actions are executed before the interactive part. * `display-last-changes`: display your last changes * `tests-check`: run the project test suite * Option `command`: command to run (default: *phpunit*) - * Option `timeout`: the number of seconds after which the command times out (default: *60.0*) + * Option `timeout`: the amount of seconds after which the command times out (default: *60.0*) * Option `expected_exit_code`: expected return code (default: *0*) -* `composer-json-check`: run a validate on the composer.json +* `composer-json-check`: run a validated on the composer.json * Option `composer`: how to run composer (default: *php composer.phar*) * `composer-stability-check`: will check if the composer.json is set to the right minimum-stability * Option `stability`: the stability that should be set in the minimum-stability field (default: *stable*) @@ -192,7 +192,7 @@ Actions can be used for pre or post release parts. * Option `file`: path from .rmt.yml to changelog file (default: *CHANGELOG*) * Option `dump-commits`: write all commit messages since the last release into the changelog file (default: *false*) - * Option `insert-at`: only for addTop formatter: Number of lines to skip from the + * Option `insert-at`: only for addTop formatter: Amount lines to skip from the top of the changelog file before adding the release number (default: *0*) * Option `exclude-merge-commits`: Exclude merge commits from the changelog (default: *false*) * `vcs-commit`: commit all files of the working copy (only use it with the @@ -200,13 +200,13 @@ Actions can be used for pre or post release parts. * Option `commit-message`: specify a custom commit message. %version% will be replaced by the current / next version strings. * `vcs-tag`: Tag the last commit * `vcs-publish`: Publish the changes (commits and tags) -* `composer-update`: Update the version number in a composer file (note that when using packagist.org, it is recommended to not have a tag in composer.json as the version is handle by version control tags) +* `composer-update`: Update the version number in a composer file (note that when using packagist.org, it is recommended to not have a tag in composer.json as the version is handled by version control tags) * `files-update`: Update the version in one or multiple files. For each file to update, please provide an array with * Option `file`: path to the file to update * Option `pattern`: optional, use to specify the string replacement pattern in your file. For example: `const VERSION = '%version%';` * `build-phar-package`: Builds a Phar package of the current project whose filename depends on the 'package-name' option and the deployed version: [package-name]-[version].phar - * Option `package-name`: the name of the generate package + * Option `package-name`: the name of the generated package * Option `destination`: the destination directory to build the package into. If prefixed with a slash, is considered absolute, otherwise relative to the project root. * Option `excluded-paths`: a regex of excluded paths, directly passed to the [Phar::buildFromDirectory](http://php.net/manual/en/phar.buildfromdirectory.php) method. Ex: `/^(?!.*cookbooks|.*\.vagrant|.*\.idea).*$/im` * Option `metadata`: an array of metadata describing the package. Ex author, project. Note: the release version is added by default but can be overridden here. @@ -228,7 +228,7 @@ Actions can be used for pre or post release parts. Extend it --------- -RMT is providing some existing actions, generators, and persisters. If needed you can add your own by creating a PHP script in your project, and referencing it in the configuration via it's relative path: +RMT is providing some existing actions, generators and persisters. If needed you can add your own by creating a PHP script in your project, and referencing it in the configuration via it's relative path: version-generator: "bin/myOwnGenerator.php" @@ -284,7 +284,7 @@ Most of the time, it will be easier for you to pick up an example below and adap prerequisites: [working-copy-check, display-last-changes] -### Using Git tags with prefix, semantic versioning, updating two files and pushing automatically +### Using Git tags with a prefix, semantic versioning, updating two files and pushing automatically vcs: git version-generator: semantic @@ -308,8 +308,8 @@ Most of the time, it will be easier for you to pick up an example below and adap tag-prefix: "{branch-name}_" post-release-actions: [vcs-publish] - # This entry allow to override some parameters for the master branch - master: + # This entry allow to override some parameters for the main branch + main: prerequisites: [working-copy-check, display-last-changes] pre-release-actions: changelog-update: @@ -325,7 +325,7 @@ Most of the time, it will be easier for you to pick up an example below and adap Contributing ------------ -If you would like to help, by submitting one of your action scripts, generators, or persisters. Or just by reporting a +If you would like to help, by submitting one of your action scripts, generators or persisters. Or just by reporting a bug just go to the project page [https://github.com/liip/RMT](https://github.com/liip/RMT). If you provide a PR, try to associate it some unit or functional tests. See next section diff --git a/src/Liip/RMT/Config/templates/default-vcs-config.yml.tmpl b/src/Liip/RMT/Config/templates/default-vcs-config.yml.tmpl index 64c06da6..a0bfa088 100644 --- a/src/Liip/RMT/Config/templates/default-vcs-config.yml.tmpl +++ b/src/Liip/RMT/Config/templates/default-vcs-config.yml.tmpl @@ -24,8 +24,8 @@ _default: ask-confirmation: true # BRANCH SPECIFIC CONFIG -# On master, we override the general config -master: +# On main, we override the general config +main: version-generator: %%generator%% version-persister: vcs-tag: diff --git a/test/Liip/RMT/Tests/Functional/GitTest.php b/test/Liip/RMT/Tests/Functional/GitTest.php index b6bd7a79..3c429b55 100644 --- a/test/Liip/RMT/Tests/Functional/GitTest.php +++ b/test/Liip/RMT/Tests/Functional/GitTest.php @@ -75,7 +75,6 @@ public function testTagPrefixWithBranchNamePlaceHolder(): void $this->createConfig('simple', array('name' => 'vcs-tag', 'tag-prefix' => '_{branch-name}_'), array('vcs' => 'git')); exec('./RMT release -n --confirm-first'); exec('git tag', $tags); -// $this->manualDebug(); - self::assertEquals(array('_master_1'), $tags); + self::assertEquals(array('_main_1'), $tags); } } diff --git a/test/Liip/RMT/Tests/Functional/InitCommandTest.php b/test/Liip/RMT/Tests/Functional/InitCommandTest.php index d89ea3ba..d49af52a 100644 --- a/test/Liip/RMT/Tests/Functional/InitCommandTest.php +++ b/test/Liip/RMT/Tests/Functional/InitCommandTest.php @@ -28,14 +28,14 @@ public function testInitConfig(): void $config = Yaml::parse(file_get_contents($configFile), true); $defaultConfig = $config['_default']; - $masterConfig = $config['master']; + $mainConfig = $config['main']; self::assertEquals('git', $defaultConfig['vcs']); self::assertEquals('simple', $defaultConfig['version-generator']); - self::assertEquals('semantic', $masterConfig['version-generator']); + self::assertEquals('semantic', $mainConfig['version-generator']); self::assertEquals(array('vcs-tag' => array('tag-prefix' => '{branch-name}_')), $defaultConfig['version-persister']); - self::assertEquals(array('vcs-tag' => array('tag-prefix' => '')), $masterConfig['version-persister']); + self::assertEquals(array('vcs-tag' => array('tag-prefix' => '')), $mainConfig['version-persister']); } } diff --git a/test/Liip/RMT/Tests/Unit/VCS/GitTest.php b/test/Liip/RMT/Tests/Unit/VCS/GitTest.php index d7b1a3d8..782ef3f6 100644 --- a/test/Liip/RMT/Tests/Unit/VCS/GitTest.php +++ b/test/Liip/RMT/Tests/Unit/VCS/GitTest.php @@ -82,11 +82,11 @@ public function testSaveWorkingCopy(): void public function testGetCurrentBranch(): void { $vcs = new Git(); - self::assertEquals('master', $vcs->getCurrentBranch()); + self::assertEquals('main', $vcs->getCurrentBranch()); system('git checkout -b foo --quiet'); self::assertEquals('foo', $vcs->getCurrentBranch()); - exec('git checkout master --quiet'); - self::assertEquals('master', $vcs->getCurrentBranch()); + exec('git checkout main --quiet'); + self::assertEquals('main', $vcs->getCurrentBranch()); } public function testGetCurrentBranchWhenNotInBranch(): void @@ -104,7 +104,7 @@ public function testChangeNoMergeCommits(): void $vcs = new Git(); exec('git checkout -b merge-branch --quiet'); exec('echo "text" > new-file && git add -A && git commit -m "First commit"'); - exec('git checkout master --quiet'); + exec('git checkout main --quiet'); exec('git merge --no-ff merge-branch'); $modifs = $vcs->getAllModificationsSince('1.1.0', false, true); @@ -119,7 +119,7 @@ public function testChangeWithMergeCommits(): void $vcs = new Git(); exec('git checkout -b merge-branch --quiet'); exec('echo "text" > new-file && git add -A && git commit -m "First commit"'); - exec('git checkout master --quiet'); + exec('git checkout main --quiet'); exec('git merge --no-ff merge-branch'); $modifs = $vcs->getAllModificationsSince('1.1.0'); From cde44455dc9570811cfcb03c2a1b659ceaa81dfc Mon Sep 17 00:00:00 2001 From: Sickenberg Romain Date: Wed, 30 Mar 2022 14:51:55 +0200 Subject: [PATCH 02/13] docs(readme): removed the remaining `master` --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5288f809..22d321fa 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ RMT also support JSON configs, but we recommend using YAML. ### Branch specific config Sometimes you want to use a different release strategy according to the VCS branch, e.g. you want to add CHANGELOG entries only in the `master` branch. To do so, you have to place your default config into a root element named `_default`, then you can override parts of this default config for the -branch `master`. Example: +branch `main`. Example: _default: version-generator: "simple" From cd3b975a8f633116b92efd6f99c41581c022ed70 Mon Sep 17 00:00:00 2001 From: Sickenberg Romain Date: Wed, 30 Mar 2022 18:00:03 +0200 Subject: [PATCH 03/13] test(zip_archive): changed the zip archive branch from master to main Sorry for this, didn't knew the existence of this file --- test/Liip/RMT/Tests/Unit/VCS/gitRepo.zip | Bin 18111 -> 18887 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/test/Liip/RMT/Tests/Unit/VCS/gitRepo.zip b/test/Liip/RMT/Tests/Unit/VCS/gitRepo.zip index b4a96aaca05d61c8330cb65713270dfdb3af09a7..4a55474212b1568d1d904b5db9f4a929c3a4d9c9 100644 GIT binary patch delta 2115 zcmZuy2~<;88h$q~AVEMRYzYK|$QBU-1VX^X0105MvLvZMIY?N96bzdSHcE7G8LDH! z-vdGgSww5C=h#6ioigG!wFMm=3Q`tpqc*l!tWY@Ndvzwq1jP_3pZ=CZD+C%KO%8*+p61K}RoIr>9@mvXD#GB7?<)iLEKO|JqagaN+Np z9mdMgwyI&Ks&3D3?{J@;KADyNV_0oh_Gsggi^}~~le~ZpKlCN?W0LA)H4W8ioPr0t z=Z_XYiOIKIE%VyVz82Zl_h{mgPp)Oh71sLa<2E?cP(9k@s@uBIDmwoDpR#cH{-WkQcW3M7E=H~0$k*=u znj#&|$tAzB{KUxiS8Ho-ojkXZZ~y3Fv18>T!Y&pz?EUH+bx(P>tj$^irW&`IvXNY1V$)S3LbU!6`r{U6mhW zRu{&+ZQ+@RBm8CA-;560EBqUgDZ1Xz0m8YqZ|@+VdmJ%vBb_WTa_iW!1KE)T!^&_B zV?a6ES+_x@*38iR|Io1E;0+lbXuJ2uGv5-$uF!7{g}yC!S3Yiu=hnS5+^?a0weLpZ zv3EZ!ORkSLKW}x7zv9wV*X4r#RC9Xkc-0c=%2c1GjBgX7PAFtC!%K#OBY(+1SuMO6 zd!T^c-BY5wqcp7%U3%F;W81au>KDq{90_N>l1D2l-QtR*Aet5Ql7F zaj?Ytt$GHf!5$_R()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;Zcf$&UzafbSnVjqSaF&{Qdy`fgg$7PVI z5_#H{Com6F4E?VYp(0L3?D9Y-hBI*vsMBy@LA(OgY6(~|58jA3&HIlbp*LPK!)IW* zh3_{PEg~*q7a!d*gn&eCqn#9j?UV$bs3YLKT1bCMBN(PbNv_8WAz986)B;Ep{=w(7x;YJs%H%3BvqOV`Ti`QaXu>tCnLSQN-2ySY;;9L@eKO@K@m`t+b zS0E)h3$KR#$qxFk7{L><7Q#~WI2@cQ4!Tl;;Ic#u4+%0K;+8q+HBtoUq*}PROiztU zVUEs@m5`@%Qy0QvkR&`%=-oIHPU#)k)o5^IIlN_X&|75)24z~9XVhZ~GK>y-Wh8>O zNG;qThy_Hc4!j?#Q{A`&CP<9HYI0LoqT!;+PKU@5)XKHsFzczG<#5n!$6^>ayKxc} zTXOLG&~3?~uEao4ni7~~KIn`*e}VFObJ)Jb6c^?fxMHB*#LTqdXc~j_p(||-HK>He f)@&kIX?-0Zf_|&YpX){1k2K`^n4CI(v26A?_NCE0 From b39f1b1356b104f8a1a7e0595377f8ae82c69bb3 Mon Sep 17 00:00:00 2001 From: Sickenberg Romain Date: Wed, 30 Mar 2022 18:00:59 +0200 Subject: [PATCH 04/13] refactor(zip_archive): Removed master branch from the archive --- test/Liip/RMT/Tests/Unit/VCS/gitRepo.zip | Bin 18887 -> 19088 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/test/Liip/RMT/Tests/Unit/VCS/gitRepo.zip b/test/Liip/RMT/Tests/Unit/VCS/gitRepo.zip index 4a55474212b1568d1d904b5db9f4a929c3a4d9c9..55348a79744637a00470c9eee5b4e89c3470b2cb 100644 GIT binary patch delta 450 zcmX>;nQ_8YMxFp~W)?065D=O$kw=DOah*%j3Lu_5QAKj1XB-nybfpp-NOW=C#*3ZO zOpEI_$H;`S03{}GQP4rC4`h;@yupBFGppiiR-mHE2X%!vA63g`fwA4SqZuJ=iOqX- zRxz^(O{fc*+@K*kx!ynk#hA?-3^p*=GqZ>Q9mN53R$Yi#teKQ1kf#U40t_+?dg+-Z z`UQ!}*{LbIMX71Up&^_M%n&!aB$ZZhGcdAzWn^Fgn-CnP;o)=cny#0xc9_O_os%1a zG(3FIdin->XrDc~@=9w_*XM4p1`%5@fPHr$~ne4&Hx4F>tBP&QM#o7uewRwT{N^Xe15*?)`r@Ko+)GKaY>@L7Gd4UC& uC8lpAfPP|N0J@f8Nn@M|(2p2?V+Hwb@&ZpuJ}U+*hLxfW3>Sgw7#IMfRfs77 delta 262 zcmbO*mGSswMxFp~W)?065HRnb$Roq?v(_a^s?H^8@M8wh~(O#ZFFHCfDqZ}TC8dCWYFOmfUHCrrL?qQwGo!(>4R`N=w_ zp+E;rZZhX d$p$too5ef?m_%6FK;E Date: Thu, 31 Mar 2022 19:45:24 +0200 Subject: [PATCH 05/13] WIP, please discard --- .gitignore | 1 + .rmt.yml | 4 +++- src/Liip/RMT/Command/BaseCommand.php | 2 +- src/Liip/RMT/Config/Handler.php | 11 +++++------ .../RMT/Config/templates/default-vcs-config.yml.tmpl | 4 +++- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 931cac4c..b65b922a 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ cache.properties bin !bin/UpdateApplicationVersionCurrentVersion.php .phpunit.result.cache +.idea/ diff --git a/.rmt.yml b/.rmt.yml index 8b433a5e..16fd25f4 100644 --- a/.rmt.yml +++ b/.rmt.yml @@ -1,4 +1,6 @@ -vcs: git +vcs: + name: git + main-branch: main prerequisites: - working-copy-check: diff --git a/src/Liip/RMT/Command/BaseCommand.php b/src/Liip/RMT/Command/BaseCommand.php index f71c6e62..e3ad0ecd 100644 --- a/src/Liip/RMT/Command/BaseCommand.php +++ b/src/Liip/RMT/Command/BaseCommand.php @@ -82,7 +82,7 @@ public function loadContext(): void try { $branch = $vcs->getCurrentBranch(); } catch (\Exception $e) { - echo "\033[31mImpossible to read the branch name\033[37m"; + echo "\033[31mUnable to read the branch name\033[37m"; } if (isset($branch)) { $config = $configHandler->getConfigForBranch($branch); diff --git a/src/Liip/RMT/Config/Handler.php b/src/Liip/RMT/Config/Handler.php index 83687f6b..e5c1780d 100644 --- a/src/Liip/RMT/Config/Handler.php +++ b/src/Liip/RMT/Config/Handler.php @@ -25,7 +25,7 @@ public function __construct($rawConfig = null, $projectRoot = null) public function getDefaultConfig() { return array( - 'vcs' => null, + 'vcs' => array(), 'prerequisites' => array(), 'pre-release-actions' => array(), 'version-generator' => null, @@ -69,7 +69,7 @@ protected function mergeConfig($branchName = null) } // Return custom branch config - if (isset($branchName) && isset($branchesConfig[$branchName])) { + if (isset($branchName, $branchesConfig[$branchName])) { return array_replace_recursive($baseConfig, $branchesConfig[$branchName]); } @@ -97,7 +97,6 @@ protected function normalize($config) // Same process but for list value elements foreach (array('prerequisites', 'pre-release-actions', 'post-release-actions') as $configKey) { foreach ($config[$configKey] as $key => $item) { - // Accept the element to be define by key or by value if (!is_numeric($key)) { if ($item == null) { @@ -142,7 +141,7 @@ protected function getClassAndOptions($rawConfig, $sectionName) } elseif (is_array($rawConfig)) { // Handling Yml corner case (see https://github.com/liip/RMT/issues/54) - if (count($rawConfig) == 1 && key($rawConfig) !== 'name') { + if (count($rawConfig) === 1 && key($rawConfig) !== 'name') { $name = key($rawConfig); $rawConfig = is_array(reset($rawConfig)) ? reset($rawConfig) : array(); $rawConfig['name'] = $name; @@ -157,7 +156,7 @@ protected function getClassAndOptions($rawConfig, $sectionName) $options = $rawConfig; } else { - throw new Exception("Invalid configuration for [$sectionName] should be a object name or an array with name and options"); + throw new Exception("Invalid configuration for [$sectionName] should be an object name or an array with name and options"); } return array('class' => $class, 'options' => $options); @@ -177,7 +176,7 @@ protected function findClass($name, $sectionName) return str_replace('.php', '', $lastPart); } else { - throw new \Liip\RMT\Exception("Impossible to open [$file] please review your config"); + throw new \Liip\RMT\Exception("Unable to open [$file] please review your config"); } } diff --git a/src/Liip/RMT/Config/templates/default-vcs-config.yml.tmpl b/src/Liip/RMT/Config/templates/default-vcs-config.yml.tmpl index a0bfa088..959ae9c1 100644 --- a/src/Liip/RMT/Config/templates/default-vcs-config.yml.tmpl +++ b/src/Liip/RMT/Config/templates/default-vcs-config.yml.tmpl @@ -1,7 +1,9 @@ _default: # VCS CONFIG - vcs: %%vcs%% + vcs: + name: %%vcs%% + main-branch: %%main-branch%% # PREREQUISITES # Actions executed before any questions get asked to the user. From e8ceda5384d6aca3aaad9e71c4accb8e48c7570e Mon Sep 17 00:00:00 2001 From: Sickenberg Romain Date: Thu, 31 Mar 2022 19:45:24 +0200 Subject: [PATCH 06/13] WIP, please discard --- .gitignore | 1 + .rmt.yml | 4 +++- src/Liip/RMT/Command/BaseCommand.php | 2 +- src/Liip/RMT/Command/InitCommand.php | 14 +++++++++++--- src/Liip/RMT/Config/Handler.php | 11 +++++------ .../Config/templates/default-vcs-config.yml.tmpl | 6 ++++-- src/Liip/RMT/Information/InformationCollector.php | 4 ++-- 7 files changed, 27 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 931cac4c..b65b922a 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ cache.properties bin !bin/UpdateApplicationVersionCurrentVersion.php .phpunit.result.cache +.idea/ diff --git a/.rmt.yml b/.rmt.yml index 8b433a5e..16fd25f4 100644 --- a/.rmt.yml +++ b/.rmt.yml @@ -1,4 +1,6 @@ -vcs: git +vcs: + name: git + main-branch: main prerequisites: - working-copy-check: diff --git a/src/Liip/RMT/Command/BaseCommand.php b/src/Liip/RMT/Command/BaseCommand.php index f71c6e62..e3ad0ecd 100644 --- a/src/Liip/RMT/Command/BaseCommand.php +++ b/src/Liip/RMT/Command/BaseCommand.php @@ -82,7 +82,7 @@ public function loadContext(): void try { $branch = $vcs->getCurrentBranch(); } catch (\Exception $e) { - echo "\033[31mImpossible to read the branch name\033[37m"; + echo "\033[31mUnable to read the branch name\033[37m"; } if (isset($branch)) { $config = $configHandler->getConfigForBranch($branch); diff --git a/src/Liip/RMT/Command/InitCommand.php b/src/Liip/RMT/Command/InitCommand.php index 7e26aaec..d314d9f2 100644 --- a/src/Liip/RMT/Command/InitCommand.php +++ b/src/Liip/RMT/Command/InitCommand.php @@ -70,6 +70,13 @@ protected function configure(): void 'choices_shortcuts' => array('g' => 'git', 'h' => 'hg', 'n' => 'none'), 'default' => 'none', )), + new InformationRequest('main-branch', array( + 'description' => 'The default branch you want to use', + 'type' => 'choice', + 'choices' => array('main', 'master'), + 'choices_shortcuts' => array('m' => 'main', 'mst' => 'master'), + 'default' => 'main', + )), new InformationRequest('generator', array( 'description' => 'The generator to use for version incrementing', 'type' => 'choice', @@ -153,18 +160,19 @@ protected function execute(InputInterface $input, OutputInterface $output): int // Create the config file from a template $this->getOutput()->writeln("Creation of the config file {$this->configPath}"); - $template = $this->informationCollector->getValueFor('vcs') == 'none' ? + $template = $this->informationCollector->getValueFor('vcs') === 'none' ? __DIR__.'/../Config/templates/no-vcs-config.yml.tmpl' : __DIR__.'/../Config/templates/default-vcs-config.yml.tmpl' ; $config = file_get_contents($template); $generator = $this->informationCollector->getValueFor('generator'); foreach (array( - 'generator' => $generator == 'semantic-versioning' ? + 'generator' => $generator === 'semantic-versioning' ? 'semantic # More complex versionning (semantic)' : 'simple # Same simple versionning', 'vcs' => $this->informationCollector->getValueFor('vcs'), + 'main-branch' => $this->informationCollector->getValueFor('main-branch'), 'persister' => $this->informationCollector->getValueFor('persister'), - 'changelog-format' => $generator == 'semantic-versioning' ? 'semantic' : 'simple', + 'changelog-format' => $generator === 'semantic-versioning' ? 'semantic' : 'simple', ) as $key => $value) { $config = str_replace("%%$key%%", $value, $config); } diff --git a/src/Liip/RMT/Config/Handler.php b/src/Liip/RMT/Config/Handler.php index 83687f6b..e5c1780d 100644 --- a/src/Liip/RMT/Config/Handler.php +++ b/src/Liip/RMT/Config/Handler.php @@ -25,7 +25,7 @@ public function __construct($rawConfig = null, $projectRoot = null) public function getDefaultConfig() { return array( - 'vcs' => null, + 'vcs' => array(), 'prerequisites' => array(), 'pre-release-actions' => array(), 'version-generator' => null, @@ -69,7 +69,7 @@ protected function mergeConfig($branchName = null) } // Return custom branch config - if (isset($branchName) && isset($branchesConfig[$branchName])) { + if (isset($branchName, $branchesConfig[$branchName])) { return array_replace_recursive($baseConfig, $branchesConfig[$branchName]); } @@ -97,7 +97,6 @@ protected function normalize($config) // Same process but for list value elements foreach (array('prerequisites', 'pre-release-actions', 'post-release-actions') as $configKey) { foreach ($config[$configKey] as $key => $item) { - // Accept the element to be define by key or by value if (!is_numeric($key)) { if ($item == null) { @@ -142,7 +141,7 @@ protected function getClassAndOptions($rawConfig, $sectionName) } elseif (is_array($rawConfig)) { // Handling Yml corner case (see https://github.com/liip/RMT/issues/54) - if (count($rawConfig) == 1 && key($rawConfig) !== 'name') { + if (count($rawConfig) === 1 && key($rawConfig) !== 'name') { $name = key($rawConfig); $rawConfig = is_array(reset($rawConfig)) ? reset($rawConfig) : array(); $rawConfig['name'] = $name; @@ -157,7 +156,7 @@ protected function getClassAndOptions($rawConfig, $sectionName) $options = $rawConfig; } else { - throw new Exception("Invalid configuration for [$sectionName] should be a object name or an array with name and options"); + throw new Exception("Invalid configuration for [$sectionName] should be an object name or an array with name and options"); } return array('class' => $class, 'options' => $options); @@ -177,7 +176,7 @@ protected function findClass($name, $sectionName) return str_replace('.php', '', $lastPart); } else { - throw new \Liip\RMT\Exception("Impossible to open [$file] please review your config"); + throw new \Liip\RMT\Exception("Unable to open [$file] please review your config"); } } diff --git a/src/Liip/RMT/Config/templates/default-vcs-config.yml.tmpl b/src/Liip/RMT/Config/templates/default-vcs-config.yml.tmpl index a0bfa088..8a52b490 100644 --- a/src/Liip/RMT/Config/templates/default-vcs-config.yml.tmpl +++ b/src/Liip/RMT/Config/templates/default-vcs-config.yml.tmpl @@ -1,7 +1,9 @@ _default: # VCS CONFIG - vcs: %%vcs%% + vcs: + name: %%vcs%% + main-branch: %%main-branch%% # PREREQUISITES # Actions executed before any questions get asked to the user. @@ -25,7 +27,7 @@ _default: # BRANCH SPECIFIC CONFIG # On main, we override the general config -main: +%%main-branch%%: version-generator: %%generator%% version-persister: vcs-tag: diff --git a/src/Liip/RMT/Information/InformationCollector.php b/src/Liip/RMT/Information/InformationCollector.php index d9335cfd..076655a4 100644 --- a/src/Liip/RMT/Information/InformationCollector.php +++ b/src/Liip/RMT/Information/InformationCollector.php @@ -71,7 +71,7 @@ public function registerRequests($list) public function registerStandardRequest($name) { - if (!in_array($name, array_keys(static::$standardRequests))) { + if (!array_key_exists($name, static::$standardRequests)) { throw new \Exception("There is no standard request named [$name]"); } if (!isset($this->requests[$name])) { @@ -162,7 +162,7 @@ public function getValueFor($requestName, $default = null) if ($this->hasRequest($requestName)) { return $this->getRequest($requestName)->getValue(); } else { - if (func_num_args() == 2) { + if (func_num_args() === 2) { return $default; } throw new \Exception("No request named $requestName"); From 185d0007b664bb6b6ebfc04edd826baed016ef93 Mon Sep 17 00:00:00 2001 From: Sickenberg Romain Date: Thu, 31 Mar 2022 20:33:33 +0200 Subject: [PATCH 07/13] test(tests): wrote some tests --- autoload.php | 2 +- test/Liip/RMT/Tests/Functional/GitTest.php | 25 +++++++++++++++---- .../RMT/Tests/Functional/InitCommandTest.php | 7 +++--- .../Functional/RMTFunctionalTestBase.php | 2 +- .../RMT/Tests/Unit/Config/HandlerTest.php | 10 +++++--- 5 files changed, 31 insertions(+), 15 deletions(-) diff --git a/autoload.php b/autoload.php index 778cf7c2..013e9b1b 100644 --- a/autoload.php +++ b/autoload.php @@ -37,5 +37,5 @@ )); $loader->register(); } else { - throw new \Exception("Unable to find the an autoloader"); + throw new \Exception("Unable to find an autoloader"); } diff --git a/test/Liip/RMT/Tests/Functional/GitTest.php b/test/Liip/RMT/Tests/Functional/GitTest.php index 3c429b55..9e11f329 100644 --- a/test/Liip/RMT/Tests/Functional/GitTest.php +++ b/test/Liip/RMT/Tests/Functional/GitTest.php @@ -19,17 +19,35 @@ public function testInitialVersion(): void $this->createConfig('simple', 'vcs-tag', array('vcs' => 'git')); exec('./RMT release -n --confirm-first'); exec('git tag', $tags); -// $this->manualDebug(); self::assertEquals(array('1'), $tags); } + public function testInitialBranch(): void + { + $this->initGit(); + $this->createConfig('simple', 'vcs-tag', ['vcs' => 'git']); + exec('git branch --show-current', $branch); + self::assertEquals('main', $branch[0]); + } + + public function testDifferentBranchAreCorrectlySetup(): void + { + $this->initGit(); + exec('git branch -m main master'); + $this->createConfig('simple', 'vcs-tag', ['vcs' => ['name' => 'git', 'default-branch' => 'master']]); + exec('git branch --show-current', $branch); + self::assertEquals('master', $branch[0]); + exec('./RMT release -n --confirm-first'); + exec('git tag', $tags); + self::assertEquals('1', $tags[0]); + } + public function testInitialVersionSemantic(): void { $this->initGit(); $this->createConfig('semantic', 'vcs-tag', array('vcs' => 'git')); exec('./RMT release -n --type=patch --confirm-first'); exec('git tag', $tags); -// $this->manualDebug(); self::assertEquals(array('0.0.1'), $tags); } @@ -42,7 +60,6 @@ public function testSimple(): void $this->createConfig('simple', 'vcs-tag', array('vcs' => 'git')); exec('./RMT release -n'); exec('git tag', $tags); -// $this->manualDebug(); self::assertEquals(array('1', '3', '4', 'toto'), $tags); } @@ -53,7 +70,6 @@ public function testSemantic(): void $this->createConfig('semantic', 'vcs-tag', array('vcs' => 'git')); exec('./RMT release -n --type=minor'); exec('git tag', $tags); -// $this->manualDebug(); self::assertEquals(array('2.1.19', '2.2.0'), $tags); } @@ -65,7 +81,6 @@ public function testTagPrefix(): void $this->createConfig('simple', array('name' => 'vcs-tag', 'tag-prefix' => 'v_'), array('vcs' => 'git')); exec('./RMT release -n'); exec('git tag', $tags); -// $this->manualDebug(); self::assertEquals(array('2', 'v_1', 'v_2'), $tags); } diff --git a/test/Liip/RMT/Tests/Functional/InitCommandTest.php b/test/Liip/RMT/Tests/Functional/InitCommandTest.php index d49af52a..8565445a 100644 --- a/test/Liip/RMT/Tests/Functional/InitCommandTest.php +++ b/test/Liip/RMT/Tests/Functional/InitCommandTest.php @@ -20,9 +20,7 @@ public function testInitConfig(): void $configFile = '.rmt.yml'; unlink($configFile); self::assertFileDoesNotExist($configFile); - exec('./RMT init --configonly=n --vcs=git --generator=semantic-versioning --persister=vcs-tag -n'); - -// $this->manualDebug(); + exec('./RMT init --configonly=n --vcs=git --main-branch=main --generator=semantic-versioning --persister=vcs-tag -n'); self::assertFileExists($configFile); $config = Yaml::parse(file_get_contents($configFile), true); @@ -30,7 +28,8 @@ public function testInitConfig(): void $defaultConfig = $config['_default']; $mainConfig = $config['main']; - self::assertEquals('git', $defaultConfig['vcs']); + self::assertEquals('git', $defaultConfig['vcs']['name']); + self::assertEquals('main', $defaultConfig['vcs']['main-branch']); self::assertEquals('simple', $defaultConfig['version-generator']); self::assertEquals('semantic', $mainConfig['version-generator']); diff --git a/test/Liip/RMT/Tests/Functional/RMTFunctionalTestBase.php b/test/Liip/RMT/Tests/Functional/RMTFunctionalTestBase.php index 12b1499f..a41cf1ec 100644 --- a/test/Liip/RMT/Tests/Functional/RMTFunctionalTestBase.php +++ b/test/Liip/RMT/Tests/Functional/RMTFunctionalTestBase.php @@ -30,7 +30,7 @@ protected function setUp(): void // Create the executable task inside $rmtDir = realpath(__DIR__ . '/../../../../../'); - exec("php $rmtDir/command.php init --configonly=n --generator=basic-increment --persister=vcs-tag --vcs=git"); + exec("php $rmtDir/command.php init --configonly=n --generator=basic-increment --persister=vcs-tag --vcs=git --main-branch=main"); } protected function createConfig($generator, $persister, $otherConfig = array()): void diff --git a/test/Liip/RMT/Tests/Unit/Config/HandlerTest.php b/test/Liip/RMT/Tests/Unit/Config/HandlerTest.php index b3375a12..388a21b6 100644 --- a/test/Liip/RMT/Tests/Unit/Config/HandlerTest.php +++ b/test/Liip/RMT/Tests/Unit/Config/HandlerTest.php @@ -139,7 +139,7 @@ public function testMerge(): void $method->setAccessible(true); self::assertEquals([ - 'vcs' => null, + 'vcs' => [], 'prerequisites' => [], 'pre-release-actions' => [], 'post-release-actions' => [], @@ -148,7 +148,7 @@ public function testMerge(): void ], $method->invokeArgs($configHandler, [])); self::assertEquals([ - 'vcs' => null, + 'vcs' => [], 'prerequisites' => [], 'pre-release-actions' => [], 'post-release-actions' => [], @@ -173,7 +173,7 @@ public function testMergeOptions(): void $method->setAccessible(true); self::assertEquals([ - 'vcs' => null, + 'vcs' => [], 'prerequisites' => [], 'pre-release-actions' => [], 'post-release-actions' => [], @@ -182,7 +182,7 @@ public function testMergeOptions(): void ], $method->invokeArgs($configHandler, [])); self::assertEquals([ - 'vcs' => null, + 'vcs' => [], 'prerequisites' => [], 'pre-release-actions' => [], 'post-release-actions' => [], @@ -227,6 +227,8 @@ public function getDataForTestingGetClassAndOptions(): array ['vcs', ['name' => 'git'], Git::class, []], // vcs: {name: git, opt1: val1} ['vcs', ['name' => 'git', 'opt1' => 'val1'], Git::class, ['opt1' => 'val1']], + // vcs: {name: git, default-branch: liip} + ['vcs', ['name' => 'git', 'default-branch' => 'liip'], Git::class, ['default-branch' => 'liip']], ['prerequisites_1', 'vcs-clean-check', 'Liip\RMT\Prerequisite\VcsCleanCheck', []], ]; } From 82364c304a0e8edb87333c027245915b01eefe90 Mon Sep 17 00:00:00 2001 From: Sickenberg Romain Date: Thu, 31 Mar 2022 22:50:55 +0200 Subject: [PATCH 08/13] refactor(pr): apply preliminary pr corrections --- .gitignore | 1 - .rmt.yml | 4 +--- README.md | 12 +++++++++--- src/Liip/RMT/Command/InitCommand.php | 6 +++--- .../RMT/Config/templates/default-vcs-config.yml.tmpl | 2 +- test/Liip/RMT/Tests/Functional/GitTest.php | 8 ++++++++ 6 files changed, 22 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index b65b922a..931cac4c 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,3 @@ cache.properties bin !bin/UpdateApplicationVersionCurrentVersion.php .phpunit.result.cache -.idea/ diff --git a/.rmt.yml b/.rmt.yml index 16fd25f4..8b433a5e 100644 --- a/.rmt.yml +++ b/.rmt.yml @@ -1,6 +1,4 @@ -vcs: - name: git - main-branch: main +vcs: git prerequisites: - working-copy-check: diff --git a/README.md b/README.md index 22d321fa..a32d90c9 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ RMT - Release Management Tool [![Total Downloads](https://poser.pugx.org/liip/RMT/d/total.png)](https://packagist.org/packages/liip/RMT) [![License](https://poser.pugx.org/liip/rmt/license.svg)](https://packagist.org/packages/liip/rmt) -RMT is a handy tool to help releasing a new versions of your software. You can define the type +RMT is a handy tool to help releasing new versions of your software. You can define the type of version generator you want to use (e.g. semantic versioning), where you want to store the version (e.g. in a changelog file or as a VCS tag) and a list of actions that should be executed before or after the release of a new version. @@ -122,7 +122,7 @@ RMT also support JSON configs, but we recommend using YAML. ### Branch specific config -Sometimes you want to use a different release strategy according to the VCS branch, e.g. you want to add CHANGELOG entries only in the `master` branch. To do so, you have to place your default config into a root element named `_default`, then you can override parts of this default config for the +Sometimes you want to use a different release strategy according to the VCS branch, e.g. you want to add CHANGELOG entries only in the `main` branch. To do so, you have to place your default config into a root element named `_default`, then you can override parts of this default config for the branch `main`. Example: _default: @@ -297,7 +297,7 @@ Most of the time, it will be easier for you to pick up an example below and adap - [app.ini, 'dynamic-version: %version%'] post-release-actions: [vcs-publish] -### Using semantic versioning on master and simple versioning on topic branches, markdown formatting for changelog +### Using semantic versioning on main and simple versioning on topic branches, markdown formatting for changelog _default: vcs: git @@ -323,6 +323,12 @@ Most of the time, it will be easier for you to pick up an example below and adap version-generator: semantic version-persister: vcs-tag +### Changing the default-branch: + _default: + vcs: + name: git + default-branch: my-default-branch + Contributing ------------ If you would like to help, by submitting one of your action scripts, generators or persisters. Or just by reporting a diff --git a/src/Liip/RMT/Command/InitCommand.php b/src/Liip/RMT/Command/InitCommand.php index d314d9f2..adfeeb85 100644 --- a/src/Liip/RMT/Command/InitCommand.php +++ b/src/Liip/RMT/Command/InitCommand.php @@ -71,10 +71,10 @@ protected function configure(): void 'default' => 'none', )), new InformationRequest('main-branch', array( - 'description' => 'The default branch you want to use', + 'description' => 'The default branch you want to use (select none if you are not using a VCS system)', 'type' => 'choice', - 'choices' => array('main', 'master'), - 'choices_shortcuts' => array('m' => 'main', 'mst' => 'master'), + 'choices' => array('main', 'master', 'none'), + 'choices_shortcuts' => array('m' => 'main', 'mst' => 'master', 'n' => 'none'), 'default' => 'main', )), new InformationRequest('generator', array( diff --git a/src/Liip/RMT/Config/templates/default-vcs-config.yml.tmpl b/src/Liip/RMT/Config/templates/default-vcs-config.yml.tmpl index 8a52b490..519cc35a 100644 --- a/src/Liip/RMT/Config/templates/default-vcs-config.yml.tmpl +++ b/src/Liip/RMT/Config/templates/default-vcs-config.yml.tmpl @@ -26,7 +26,7 @@ _default: ask-confirmation: true # BRANCH SPECIFIC CONFIG -# On main, we override the general config +# On %%main-branch%%, we override the general config %%main-branch%%: version-generator: %%generator%% version-persister: diff --git a/test/Liip/RMT/Tests/Functional/GitTest.php b/test/Liip/RMT/Tests/Functional/GitTest.php index 9e11f329..d40b29bb 100644 --- a/test/Liip/RMT/Tests/Functional/GitTest.php +++ b/test/Liip/RMT/Tests/Functional/GitTest.php @@ -19,6 +19,7 @@ public function testInitialVersion(): void $this->createConfig('simple', 'vcs-tag', array('vcs' => 'git')); exec('./RMT release -n --confirm-first'); exec('git tag', $tags); + // $this->manualDebug(); self::assertEquals(array('1'), $tags); } @@ -27,6 +28,7 @@ public function testInitialBranch(): void $this->initGit(); $this->createConfig('simple', 'vcs-tag', ['vcs' => 'git']); exec('git branch --show-current', $branch); + // $this->manualDebug(); self::assertEquals('main', $branch[0]); } @@ -39,6 +41,7 @@ public function testDifferentBranchAreCorrectlySetup(): void self::assertEquals('master', $branch[0]); exec('./RMT release -n --confirm-first'); exec('git tag', $tags); + // $this->manualDebug(); self::assertEquals('1', $tags[0]); } @@ -48,6 +51,7 @@ public function testInitialVersionSemantic(): void $this->createConfig('semantic', 'vcs-tag', array('vcs' => 'git')); exec('./RMT release -n --type=patch --confirm-first'); exec('git tag', $tags); + // $this->manualDebug(); self::assertEquals(array('0.0.1'), $tags); } @@ -60,6 +64,7 @@ public function testSimple(): void $this->createConfig('simple', 'vcs-tag', array('vcs' => 'git')); exec('./RMT release -n'); exec('git tag', $tags); + // $this->manualDebug(); self::assertEquals(array('1', '3', '4', 'toto'), $tags); } @@ -70,6 +75,7 @@ public function testSemantic(): void $this->createConfig('semantic', 'vcs-tag', array('vcs' => 'git')); exec('./RMT release -n --type=minor'); exec('git tag', $tags); + // $this->manualDebug(); self::assertEquals(array('2.1.19', '2.2.0'), $tags); } @@ -81,6 +87,7 @@ public function testTagPrefix(): void $this->createConfig('simple', array('name' => 'vcs-tag', 'tag-prefix' => 'v_'), array('vcs' => 'git')); exec('./RMT release -n'); exec('git tag', $tags); + // $this->manualDebug(); self::assertEquals(array('2', 'v_1', 'v_2'), $tags); } @@ -90,6 +97,7 @@ public function testTagPrefixWithBranchNamePlaceHolder(): void $this->createConfig('simple', array('name' => 'vcs-tag', 'tag-prefix' => '_{branch-name}_'), array('vcs' => 'git')); exec('./RMT release -n --confirm-first'); exec('git tag', $tags); + // $this->manualDebug(); self::assertEquals(array('_main_1'), $tags); } } From 86e4ce8ea53c98470aa6aa7f52117f0a8aed6bb6 Mon Sep 17 00:00:00 2001 From: Sickenberg Romain Date: Thu, 31 Mar 2022 23:11:38 +0200 Subject: [PATCH 09/13] refactor(cleanup): removed test-suite un-usefull + keep master on the functionnal tests --- .../Tests/Functional/ExternalTasksTest.php | 2 +- test/Liip/RMT/Tests/Functional/GitTest.php | 36 ++++-------------- .../RMT/Tests/Functional/InitCommandTest.php | 6 +-- .../Functional/RMTFunctionalTestBase.php | 4 +- test/Liip/RMT/Tests/Unit/VCS/GitTest.php | 4 +- test/Liip/RMT/Tests/Unit/VCS/gitRepo.zip | Bin 19088 -> 18434 bytes 6 files changed, 15 insertions(+), 37 deletions(-) diff --git a/test/Liip/RMT/Tests/Functional/ExternalTasksTest.php b/test/Liip/RMT/Tests/Functional/ExternalTasksTest.php index 350de104..7662b482 100644 --- a/test/Liip/RMT/Tests/Functional/ExternalTasksTest.php +++ b/test/Liip/RMT/Tests/Functional/ExternalTasksTest.php @@ -20,7 +20,7 @@ public function testInvalidScript(): void exec('./RMT release -n', $output); $output = implode("\n", $output); // $this->manualDebug(); - self::assertStringContainsString('Impossible to open', $output); + self::assertStringContainsString('Unable to open', $output); self::assertStringContainsString($scriptName, $output); } diff --git a/test/Liip/RMT/Tests/Functional/GitTest.php b/test/Liip/RMT/Tests/Functional/GitTest.php index d40b29bb..e0781b2e 100644 --- a/test/Liip/RMT/Tests/Functional/GitTest.php +++ b/test/Liip/RMT/Tests/Functional/GitTest.php @@ -19,39 +19,17 @@ public function testInitialVersion(): void $this->createConfig('simple', 'vcs-tag', array('vcs' => 'git')); exec('./RMT release -n --confirm-first'); exec('git tag', $tags); - // $this->manualDebug(); + // $this->manualDebug(); self::assertEquals(array('1'), $tags); } - public function testInitialBranch(): void - { - $this->initGit(); - $this->createConfig('simple', 'vcs-tag', ['vcs' => 'git']); - exec('git branch --show-current', $branch); - // $this->manualDebug(); - self::assertEquals('main', $branch[0]); - } - - public function testDifferentBranchAreCorrectlySetup(): void - { - $this->initGit(); - exec('git branch -m main master'); - $this->createConfig('simple', 'vcs-tag', ['vcs' => ['name' => 'git', 'default-branch' => 'master']]); - exec('git branch --show-current', $branch); - self::assertEquals('master', $branch[0]); - exec('./RMT release -n --confirm-first'); - exec('git tag', $tags); - // $this->manualDebug(); - self::assertEquals('1', $tags[0]); - } - public function testInitialVersionSemantic(): void { $this->initGit(); $this->createConfig('semantic', 'vcs-tag', array('vcs' => 'git')); exec('./RMT release -n --type=patch --confirm-first'); exec('git tag', $tags); - // $this->manualDebug(); +// $this->manualDebug(); self::assertEquals(array('0.0.1'), $tags); } @@ -64,7 +42,7 @@ public function testSimple(): void $this->createConfig('simple', 'vcs-tag', array('vcs' => 'git')); exec('./RMT release -n'); exec('git tag', $tags); - // $this->manualDebug(); +// $this->manualDebug(); self::assertEquals(array('1', '3', '4', 'toto'), $tags); } @@ -75,7 +53,7 @@ public function testSemantic(): void $this->createConfig('semantic', 'vcs-tag', array('vcs' => 'git')); exec('./RMT release -n --type=minor'); exec('git tag', $tags); - // $this->manualDebug(); +// $this->manualDebug(); self::assertEquals(array('2.1.19', '2.2.0'), $tags); } @@ -87,7 +65,7 @@ public function testTagPrefix(): void $this->createConfig('simple', array('name' => 'vcs-tag', 'tag-prefix' => 'v_'), array('vcs' => 'git')); exec('./RMT release -n'); exec('git tag', $tags); - // $this->manualDebug(); +// $this->manualDebug(); self::assertEquals(array('2', 'v_1', 'v_2'), $tags); } @@ -97,7 +75,7 @@ public function testTagPrefixWithBranchNamePlaceHolder(): void $this->createConfig('simple', array('name' => 'vcs-tag', 'tag-prefix' => '_{branch-name}_'), array('vcs' => 'git')); exec('./RMT release -n --confirm-first'); exec('git tag', $tags); - // $this->manualDebug(); - self::assertEquals(array('_main_1'), $tags); +// $this->manualDebug(); + self::assertEquals(sprintf('_%s_1', self::DEFAULT_FUNCTIONAL_BRANCH), $tags[0]); } } diff --git a/test/Liip/RMT/Tests/Functional/InitCommandTest.php b/test/Liip/RMT/Tests/Functional/InitCommandTest.php index 8565445a..1126fda0 100644 --- a/test/Liip/RMT/Tests/Functional/InitCommandTest.php +++ b/test/Liip/RMT/Tests/Functional/InitCommandTest.php @@ -20,16 +20,16 @@ public function testInitConfig(): void $configFile = '.rmt.yml'; unlink($configFile); self::assertFileDoesNotExist($configFile); - exec('./RMT init --configonly=n --vcs=git --main-branch=main --generator=semantic-versioning --persister=vcs-tag -n'); + exec(sprintf('./RMT init --configonly=n --vcs=git --main-branch=%s --generator=semantic-versioning --persister=vcs-tag -n', self::DEFAULT_FUNCTIONAL_BRANCH)); self::assertFileExists($configFile); $config = Yaml::parse(file_get_contents($configFile), true); $defaultConfig = $config['_default']; - $mainConfig = $config['main']; + $mainConfig = $config[self::DEFAULT_FUNCTIONAL_BRANCH]; self::assertEquals('git', $defaultConfig['vcs']['name']); - self::assertEquals('main', $defaultConfig['vcs']['main-branch']); + self::assertEquals(self::DEFAULT_FUNCTIONAL_BRANCH, $defaultConfig['vcs']['main-branch']); self::assertEquals('simple', $defaultConfig['version-generator']); self::assertEquals('semantic', $mainConfig['version-generator']); diff --git a/test/Liip/RMT/Tests/Functional/RMTFunctionalTestBase.php b/test/Liip/RMT/Tests/Functional/RMTFunctionalTestBase.php index a41cf1ec..bb4e6726 100644 --- a/test/Liip/RMT/Tests/Functional/RMTFunctionalTestBase.php +++ b/test/Liip/RMT/Tests/Functional/RMTFunctionalTestBase.php @@ -17,6 +17,7 @@ class RMTFunctionalTestBase extends ForwardCompatibilityTestCase { protected $tempDir; + protected const DEFAULT_FUNCTIONAL_BRANCH = 'master'; protected function setUp(): void { @@ -30,7 +31,7 @@ protected function setUp(): void // Create the executable task inside $rmtDir = realpath(__DIR__ . '/../../../../../'); - exec("php $rmtDir/command.php init --configonly=n --generator=basic-increment --persister=vcs-tag --vcs=git --main-branch=main"); + exec("php $rmtDir/command.php init --configonly=n --generator=basic-increment --persister=vcs-tag --vcs=git --main-branch=" . self::DEFAULT_FUNCTIONAL_BRANCH); } protected function createConfig($generator, $persister, $otherConfig = array()): void @@ -60,6 +61,7 @@ protected function tearDown(): void protected function initGit(): void { + exec('git config --global init.defaultBranch ' . self::DEFAULT_FUNCTIONAL_BRANCH); exec('git init'); exec('git add .'); exec('git commit -m "First commit"'); diff --git a/test/Liip/RMT/Tests/Unit/VCS/GitTest.php b/test/Liip/RMT/Tests/Unit/VCS/GitTest.php index 782ef3f6..c25095d7 100644 --- a/test/Liip/RMT/Tests/Unit/VCS/GitTest.php +++ b/test/Liip/RMT/Tests/Unit/VCS/GitTest.php @@ -82,11 +82,9 @@ public function testSaveWorkingCopy(): void public function testGetCurrentBranch(): void { $vcs = new Git(); - self::assertEquals('main', $vcs->getCurrentBranch()); + self::assertEquals('master', $vcs->getCurrentBranch()); system('git checkout -b foo --quiet'); self::assertEquals('foo', $vcs->getCurrentBranch()); - exec('git checkout main --quiet'); - self::assertEquals('main', $vcs->getCurrentBranch()); } public function testGetCurrentBranchWhenNotInBranch(): void diff --git a/test/Liip/RMT/Tests/Unit/VCS/gitRepo.zip b/test/Liip/RMT/Tests/Unit/VCS/gitRepo.zip index 55348a79744637a00470c9eee5b4e89c3470b2cb..61b4bb29539577da7e7be67cf7763853cbac426e 100644 GIT binary patch delta 1989 zcmZWp3s_TS7(VAehr1gCHZEff7%-S1o4CQo7%-4A0Tpye-cT_WZ>gC0co!{F>pw7fu+DkD|M~xOzRUl8-}`=+_2j!2 zl9icG(ar?(+-$9=Vfi|a<>}r~VSy~IDIdRTXT(4a0iI0MQ;1EF>FkgW&k!w;M-_3j@WG7M>De%mX2kkhJnxf}GCET3_kY9*%p4=e92FKlYi{aN)?)tjpMi79=*-$En_XVoag6ntSS|It4+OiUdkgOQlGusBCn>ewmg(e=XH0QVsukB zrJA?Y7)KY~bMgB2+8=AWxSMJ-oV9iDl{H+vb}{Q1ckT!3j=LBA?ByLn`$Dv;ha&H) ztp_E?Gm>^5NQ+PDac$qz@840+FFj0dFuI(kk5uKtK7Zee_Q2ETl3mNI*C-}eoVs)A zMP0+fUdct)itqb()~xM|-=Ns>#ah|#`%lp6&yyciaL;bMIvGGn+wjvm!QIcxHg%OuuU~<3PR(8F{B&84Urp%M9|P98jg zq*Zm)%eP%QBW`bzU~IqRYIgOnfpfZdH6*A6%XMY=&tSz!;lFh*9X?v);9fQG#1g(JQz<`Z`{_BGJ z@s@y`oPdx+c};mgE}S#{uv=E&@!6eg&NTLWR_C7He75f{`)0RO^H)7>yy6{u?z~#R zbhD~I9T5zN8F)DoOipjg#Y2RJI=Q+=o691RkQydAT#-v?hUMU<_KjvPTzD?%#Vgpp z7>f(xjaP!ekR^63OTg;@H)a-_XPIVa8|(;*sTa5-Jq$^~{PC_ZJ&=8xAG#q#qD^vY{`i%6p zjAQdQVipa#{3+HKD%C<%;0_gJy>FB(35QT$Qw-I!b3$gE-?pIMzhfcE^LTaKvWE$3g8iNmGTF3j2POKd^FDs zE+{eR@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w&){gM%9ltm&wLCj{_deFj vTz}lINOc>}z#!gv$uUcmn4X+uC-+~OJ#Cocsn9$y53CjcYxED?7sLJs;6q)3 From 8d5c751faeff3e16b04f336bdae22f83594feaf2 Mon Sep 17 00:00:00 2001 From: Sickenberg Romain Date: Fri, 1 Apr 2022 09:18:55 +0200 Subject: [PATCH 10/13] revert(gitrepo): revert the gitRepo with the version present in master --- test/Liip/RMT/Tests/Unit/VCS/gitRepo.zip | Bin 18434 -> 18111 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/test/Liip/RMT/Tests/Unit/VCS/gitRepo.zip b/test/Liip/RMT/Tests/Unit/VCS/gitRepo.zip index 61b4bb29539577da7e7be67cf7763853cbac426e..b4a96aaca05d61c8330cb65713270dfdb3af09a7 100644 GIT binary patch delta 1743 zcmZXV2~ZPP7{_;CNVvkX2ogzQIRXeoNWu|rVt@n(grdY_G+H?nqXJ&_!~>7%2o-@p zozgl|wV)jk2aLy9t*F?;TH1=W^*}A-h+|Pa3RBm79#1?6OT} zahIEx?3M5?mSIb|Qz7}LrHXMnZSo|8EhVT$i^3IuF)H-CM4M}6d9*oXWIDmQB*rWZ z2qNYN&pv^9wM1cKCVu_ItOz<`6*QF50-yM}@4+q}{0~3uUcpU;d9zmxqnlJ^uCn@; z4>DrDEw1T`xe(g=Ye{RK_kf%-(~hO|It%D{{{5^(ny*qwQOqmQf};E-!%E$glG$CK zlKJ5Zdy2N|=bZxpq?h_-T4mX=!z4 zKuw!yj^Js#rfubo9QC~5ja$w$0b&*Qay|t>%lf<$l}Q`uHCkJ00)OJnB6rt269a(UbMFR#J~PK6de) z#+0o4q32`)$={ISt>embV*W0BYRJiO+tnS~QZ;qP`6mmHsqDUS{arXQF>P~($ZguQ zj@{Hv-F#!Lc-_QYC7(ncwU{<(?8{F`RPv|U8&2x+-*ABVbrTn@9Fqy z-pVQeZadY#ENX7A{_y@~KR=Jw+&QyiZF6H`UeCN2f_Y_;h-al(J7N^w4V9f&mCy=l ztQ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Fb!g0%qAHA2fva;%kWzQUOacgy3!4s%F7mRDc@M{Nb44e zUlAdeAXXN~$wfHqu!h$VX8n})fds*!nM(QDp0JBUB)(nX&15MrYAYd{w5W4gkD8&=5 z>rD=aA}`?UjMTec1niM&p<5?`)HES7uweuTYGo5}GFA)g4HB5eReb0TG|u#;PKcg( zgI$M9@PX7+lf!4k2TW;3D%_UrllCk*8uNv2gOL*X5g>@yf+|x2k`y6&;0Kv0 zMx^(LjuaDgqzci1KYW~OM1dUO=uJ)?tW?s$$2qPZI>ill(4mS<2mhEQ^e4G4v$Vg>-rz};7n3jhoz?-))75U@iu-^)FB3>hfM#xv8>)GrQOF!X2_w5xm|m*jBf zR Date: Wed, 3 Dec 2025 14:18:02 +0100 Subject: [PATCH 11/13] Update src/Liip/RMT/Config/Handler.php Co-authored-by: Romain Sickenberg --- src/Liip/RMT/Config/Handler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Liip/RMT/Config/Handler.php b/src/Liip/RMT/Config/Handler.php index 88656184..a16a5195 100644 --- a/src/Liip/RMT/Config/Handler.php +++ b/src/Liip/RMT/Config/Handler.php @@ -29,7 +29,7 @@ public function __construct($rawConfig = null, $projectRoot = null) public function getDefaultConfig() { return array( - 'vcs' => array(), + 'vcs' => [], 'prerequisites' => array(), 'pre-release-actions' => array(), 'version-generator' => null, From cb03839f409bbaa492813b9fc65fd1df74a6f668 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Wed, 3 Dec 2025 15:04:21 +0100 Subject: [PATCH 12/13] Apply suggestions from code review --- test/Liip/RMT/Tests/Functional/GitTest.php | 2 +- test/Liip/RMT/Tests/Functional/InitCommandTest.php | 1 + test/Liip/RMT/Tests/Unit/VCS/GitTest.php | 6 ++++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/test/Liip/RMT/Tests/Functional/GitTest.php b/test/Liip/RMT/Tests/Functional/GitTest.php index e0781b2e..1bcf0caf 100644 --- a/test/Liip/RMT/Tests/Functional/GitTest.php +++ b/test/Liip/RMT/Tests/Functional/GitTest.php @@ -76,6 +76,6 @@ public function testTagPrefixWithBranchNamePlaceHolder(): void exec('./RMT release -n --confirm-first'); exec('git tag', $tags); // $this->manualDebug(); - self::assertEquals(sprintf('_%s_1', self::DEFAULT_FUNCTIONAL_BRANCH), $tags[0]); + self::assertEquals(['_main_1'], $tags); } } diff --git a/test/Liip/RMT/Tests/Functional/InitCommandTest.php b/test/Liip/RMT/Tests/Functional/InitCommandTest.php index 1126fda0..a906f301 100644 --- a/test/Liip/RMT/Tests/Functional/InitCommandTest.php +++ b/test/Liip/RMT/Tests/Functional/InitCommandTest.php @@ -20,6 +20,7 @@ public function testInitConfig(): void $configFile = '.rmt.yml'; unlink($configFile); self::assertFileDoesNotExist($configFile); +// $this->manualDebug(); exec(sprintf('./RMT init --configonly=n --vcs=git --main-branch=%s --generator=semantic-versioning --persister=vcs-tag -n', self::DEFAULT_FUNCTIONAL_BRANCH)); self::assertFileExists($configFile); diff --git a/test/Liip/RMT/Tests/Unit/VCS/GitTest.php b/test/Liip/RMT/Tests/Unit/VCS/GitTest.php index c25095d7..d7b1a3d8 100644 --- a/test/Liip/RMT/Tests/Unit/VCS/GitTest.php +++ b/test/Liip/RMT/Tests/Unit/VCS/GitTest.php @@ -85,6 +85,8 @@ public function testGetCurrentBranch(): void self::assertEquals('master', $vcs->getCurrentBranch()); system('git checkout -b foo --quiet'); self::assertEquals('foo', $vcs->getCurrentBranch()); + exec('git checkout master --quiet'); + self::assertEquals('master', $vcs->getCurrentBranch()); } public function testGetCurrentBranchWhenNotInBranch(): void @@ -102,7 +104,7 @@ public function testChangeNoMergeCommits(): void $vcs = new Git(); exec('git checkout -b merge-branch --quiet'); exec('echo "text" > new-file && git add -A && git commit -m "First commit"'); - exec('git checkout main --quiet'); + exec('git checkout master --quiet'); exec('git merge --no-ff merge-branch'); $modifs = $vcs->getAllModificationsSince('1.1.0', false, true); @@ -117,7 +119,7 @@ public function testChangeWithMergeCommits(): void $vcs = new Git(); exec('git checkout -b merge-branch --quiet'); exec('echo "text" > new-file && git add -A && git commit -m "First commit"'); - exec('git checkout main --quiet'); + exec('git checkout master --quiet'); exec('git merge --no-ff merge-branch'); $modifs = $vcs->getAllModificationsSince('1.1.0'); From 2ab67ccd662e6f11db7635821ac72814a1384240 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Wed, 3 Dec 2025 15:10:44 +0100 Subject: [PATCH 13/13] Update test/Liip/RMT/Tests/Functional/GitTest.php --- test/Liip/RMT/Tests/Functional/GitTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Liip/RMT/Tests/Functional/GitTest.php b/test/Liip/RMT/Tests/Functional/GitTest.php index 1bcf0caf..344877da 100644 --- a/test/Liip/RMT/Tests/Functional/GitTest.php +++ b/test/Liip/RMT/Tests/Functional/GitTest.php @@ -76,6 +76,6 @@ public function testTagPrefixWithBranchNamePlaceHolder(): void exec('./RMT release -n --confirm-first'); exec('git tag', $tags); // $this->manualDebug(); - self::assertEquals(['_main_1'], $tags); + self::assertEquals([sprintf('_%s_1', self::DEFAULT_FUNCTIONAL_BRANCH)], $tags); } }