diff --git a/end-to-end-tests/features/assert_current_version.feature b/end-to-end-tests/features/assert_current_version.feature index eb0ad41..e249c4a 100644 --- a/end-to-end-tests/features/assert_current_version.feature +++ b/end-to-end-tests/features/assert_current_version.feature @@ -3,7 +3,7 @@ Feature: The current version argument supplied is asserted to be equal or greate Scenario Outline: The current version assertion passes with batched together increments. Given the repository "" is cloned and checked out at the commit "". - When the argument --from-commit-hash is provided as "". + When the argument --from-commit-hash is provided as "". And the argument --from-version is provided as "". And the argument --current-version is provided as "". And the argument --calculation-mode is provided as "batch". @@ -11,7 +11,7 @@ Feature: The current version argument supplied is asserted to be equal or greate Examples: - | repository | checkout_commit | from_commit_hash | from_version | current_version | + | repository | checkout_commit | commit_hash | from_version | current_version | | https://github.com/yargs/yargs.git | 089417550ef5a5b8ce3578dd2a989191300b64cd | 262e796329f4a09083ca07e49f926ae43ac850e9 | 0.2.1 | 0.2.2 | | https://github.com/BlazeSoftware/atoms.git | c2dcb3e97a1bd3516bed85ff1769c30211f2337a | 46dd08718905cbdd2d056a2eac720052b9691985 | 11.0.0 | 12.0.1 | | https://github.com/gembaadvantage/uplift | ca8345039fbaceb667928d65741a43df3f72e1e6 | 30f8c01e28c70d53a25f7b20d93679d23ae0830b | 1.12.1 | 1.13.0 | @@ -19,7 +19,7 @@ Feature: The current version argument supplied is asserted to be equal or greate Scenario Outline: The current version assertion fails with batched together increments. Given the repository "" is cloned and checked out at the commit "". - When the argument --from-commit-hash is provided as "". + When the argument --from-commit-hash is provided as "". And the argument --from-version is provided as "". And the argument --current-version is provided as "". And the argument --calculation-mode is provided as "batch". @@ -27,34 +27,34 @@ Feature: The current version argument supplied is asserted to be equal or greate Examples: - | repository | checkout_commit | from_commit_hash | from_version | current_version | + | repository | checkout_commit | commit_hash | from_version | current_version | | https://github.com/yargs/yargs.git | 089417550ef5a5b8ce3578dd2a989191300b64cd | 262e796329f4a09083ca07e49f926ae43ac850e9 | 0.2.1 | 0.2.1 | | https://github.com/BlazeSoftware/atoms.git | c2dcb3e97a1bd3516bed85ff1769c30211f2337a | 46dd08718905cbdd2d056a2eac720052b9691985 | 11.0.0 | 11.0.3 | Scenario Outline: The current version assertion passes with consecutive increments. Given the repository "" is cloned and checked out at the commit "". - When the argument --from-commit-hash is provided as "". + When the argument --from-commit-hash is provided as "". And the argument --from-version is provided as "". And the argument --current-version is provided as "". Then the current version assertion passes. Examples: - | repository | checkout_commit | from_commit_hash | from_version | current_version | + | repository | checkout_commit | commit_hash | from_version | current_version | | https://github.com/istanbuljs/istanbuljs.git | 1b52fe750d1f800c34dbff168614c0c73bd76026 | 5afe20347dd3ae954b31707a67f381f87920797f | 4.1.2 | 4.2.7 | | https://gitlab.com/dmfay/massive-js.git | 482c364acf5505b81c55245fac0472890d351662 | 3f20134864b19b11541287af440540c7ad0ed986 | 2.0.1 | 3.1.0 | Scenario Outline: The current version assertion fails with consecutive increments. Given the repository "" is cloned and checked out at the commit "". - When the argument --from-commit-hash is provided as "". + When the argument --from-commit-hash is provided as "". And the argument --from-version is provided as "". And the argument --current-version is provided as "". Then the current version assertion fails. Examples: - | repository | checkout_commit | from_commit_hash | from_version | current_version | + | repository | checkout_commit | commit_hash | from_version | current_version | | https://github.com/istanbuljs/istanbuljs.git | 1b52fe750d1f800c34dbff168614c0c73bd76026 | 5afe20347dd3ae954b31707a67f381f87920797f | 4.1.2 | 4.1.3 | | https://gitlab.com/dmfay/massive-js.git | 482c364acf5505b81c55245fac0472890d351662 | 3f20134864b19b11541287af440540c7ad0ed986 | 2.0.1 | 2.1.0 | diff --git a/end-to-end-tests/features/batch_semantic_versioning.feature b/end-to-end-tests/features/batch_semantic_versioning.feature index d015bd1..f36e11d 100644 --- a/end-to-end-tests/features/batch_semantic_versioning.feature +++ b/end-to-end-tests/features/batch_semantic_versioning.feature @@ -3,14 +3,14 @@ Feature: The increments are batched together and the largest increment determine Scenario Outline: Given the repository "" is cloned and checked out at the commit "". - When the argument --from-commit-hash is provided as "". + When the argument --from-commit-hash is provided as "". And the argument --from-version is provided as "". And the argument --calculation-mode is provided as "batch". Then the returned version should be "". Examples: - | repository | checkout_commit | from_commit_hash | from_version | expected_version | + | repository | checkout_commit | commit_hash | from_version | expected_version | | https://github.com/yargs/yargs.git | 089417550ef5a5b8ce3578dd2a989191300b64cd | 262e796329f4a09083ca07e49f926ae43ac850e9 | 0.2.1 | 0.2.2 | | https://github.com/yargs/yargs.git | 027a6365b737e13116811a8ef43670196e1fa00a | 1f26de809432be9cc6f4f185629f6e5d13236598 | 0.2.3 | 0.3.0 | | https://github.com/yargs/yargs.git | 18b0b752424bf560271e670ff95a0f90c8386787 | ecfc2c474575c6cdbc6d273c94c13181bd1dbaa6 | 1.0.3 | 1.1.0 | diff --git a/end-to-end-tests/features/consecutive_semantic_versioning.feature b/end-to-end-tests/features/consecutive_semantic_versioning.feature index 669eea7..69b6bc7 100644 --- a/end-to-end-tests/features/consecutive_semantic_versioning.feature +++ b/end-to-end-tests/features/consecutive_semantic_versioning.feature @@ -3,13 +3,13 @@ Feature: The increments are applied consecutively to calculate the next semantic Scenario Outline: Given the repository "" is cloned and checked out at the commit "". - When the argument --from-commit-hash is provided as "". + When the argument --from-commit-hash is provided as "". And the argument --from-version is provided as "". Then the returned version should be "". Examples: - | repository | checkout_commit | from_commit_hash | from_version | expected_version | + | repository | checkout_commit | commit_hash | from_version | expected_version | | https://github.com/yargs/yargs.git | 089417550ef5a5b8ce3578dd2a989191300b64cd | 262e796329f4a09083ca07e49f926ae43ac850e9 | 0.2.1 | 0.2.2 | | https://github.com/yargs/yargs.git | 027a6365b737e13116811a8ef43670196e1fa00a | 1f26de809432be9cc6f4f185629f6e5d13236598 | 0.2.3 | 0.3.0 | | https://github.com/yargs/yargs.git | 18b0b752424bf560271e670ff95a0f90c8386787 | ecfc2c474575c6cdbc6d273c94c13181bd1dbaa6 | 1.0.3 | 1.1.1 | diff --git a/end-to-end-tests/features/from_arguments_conflicts.feature b/end-to-end-tests/features/from_arguments_conflicts.feature deleted file mode 100644 index 465d9a0..0000000 --- a/end-to-end-tests/features/from_arguments_conflicts.feature +++ /dev/null @@ -1,79 +0,0 @@ -Feature: The from arguments conflict with one another and can not be provided at the same time. - - - Scenario Outline: You can not provide both a reference and a commit hash. - Given the repository "" is cloned and checked out at the commit "". - When the argument --from-version is provided as "". - And the argument --from-reference is provided as "". - And the argument --from-commit-hash is provided as "". - Then their is a conflicting from arguments error. - - - Examples: - | repository | checkout_commit | from_reference | from_commit_hash | from_version | - | https://github.com/yargs/yargs.git | 0f810245494ccf13a35b7786d021b30fc95ecad5 | v15.4.0 | 028b50d5ced3b41a8dccf74107dbfc7065052a5d | 1.0.0 | - - - Scenario Outline: You can not provide both a reference and a commit hash. - Given the repository "" is cloned and checked out at the commit "". - When the argument --from-version is provided as "". - And the argument --from-commit-hash is provided as "". - And the argument --from-reference is provided as "". - Then their is a conflicting from arguments error. - - - Examples: - | repository | checkout_commit | from_reference | from_commit_hash | from_version | - | https://github.com/yargs/yargs.git | 0f810245494ccf13a35b7786d021b30fc95ecad5 | v15.4.0 | 028b50d5ced3b41a8dccf74107dbfc7065052a5d | 1.0.0 | - - - Scenario Outline: You can not provide both a reference and a commit message. - Given the repository "" is cloned and checked out at the commit "". - When the argument --from-version is provided as "". - And the flag --from-stdin is set and the standard input is "". - And the argument --from-reference is provided as "". - Then their is a conflicting from arguments error. - - - Examples: - | repository | checkout_commit | from_reference | standard_input | from_version | - | https://github.com/yargs/yargs.git | 0f810245494ccf13a35b7786d021b30fc95ecad5 | v15.4.0 | "feat: temp 13" | 1.0.0 | - - - Scenario Outline: You can not provide both a reference and a commit message. - Given the repository "" is cloned and checked out at the commit "". - When the argument --from-version is provided as "". - And the argument --from-reference is provided as "". - And the flag --from-stdin is set and the standard input is "". - Then their is a conflicting from arguments error. - - - Examples: - | repository | checkout_commit | from_reference | standard_input | from_version | - | https://github.com/yargs/yargs.git | 0f810245494ccf13a35b7786d021b30fc95ecad5 | v15.4.0 | "feat: temp 13" | 1.0.0 | - - - Scenario Outline: You can not provide both a commit message and a commit hash. - Given the repository "" is cloned and checked out at the commit "". - When the argument --from-version is provided as "". - And the flag --from-stdin is set and the standard input is "". - And the argument --from-commit-hash is provided as "". - Then their is a conflicting from arguments error. - - - Examples: - | repository | checkout_commit | standard_input | from_commit_hash | from_version | - | https://github.com/yargs/yargs.git | 0f810245494ccf13a35b7786d021b30fc95ecad5 | "feat: temp 13" | 028b50d5ced3b41a8dccf74107dbfc7065052a5d | 1.0.0 | - - - Scenario Outline: You can not provide both a commit message and a commit hash. - Given the repository "" is cloned and checked out at the commit "". - When the argument --from-version is provided as "". - And the argument --from-commit-hash is provided as "". - And the flag --from-stdin is set and the standard input is "". - Then their is a conflicting from arguments error. - - - Examples: - | repository | checkout_commit | standard_input | from_commit_hash | from_version | - | https://github.com/yargs/yargs.git | 0f810245494ccf13a35b7786d021b30fc95ecad5 | "feat: temp 13" | 028b50d5ced3b41a8dccf74107dbfc7065052a5d | 1.0.0 | diff --git a/end-to-end-tests/features/from_commit_hash.feature b/end-to-end-tests/features/from_commit_hash.feature index ac657a1..45ef1bc 100644 --- a/end-to-end-tests/features/from_commit_hash.feature +++ b/end-to-end-tests/features/from_commit_hash.feature @@ -3,41 +3,41 @@ Feature: A Git commit hash can be provided as an argument to indicate where to s Scenario Outline: Given the repository "" is cloned and checked out at the commit "". - When the argument --from-commit-hash is provided as "". + When the argument --from-commit-hash is provided as "". And the argument --from-version is provided as "". And the argument --current-version is provided as "". Then the current version assertion passes. Examples: - | repository | checkout_commit | from_commit_hash | from_version | current_version | + | repository | checkout_commit | commit_hash | from_version | current_version | | https://github.com/istanbuljs/istanbuljs.git | 1b52fe750d1f800c34dbff168614c0c73bd76026 | 5afe20347dd3ae954b31707a67f381f87920797f | 4.1.2 | 4.2.7 | | https://gitlab.com/dmfay/massive-js.git | 482c364acf5505b81c55245fac0472890d351662 | 3f20134864b19b11541287af440540c7ad0ed986 | 2.0.1 | 3.1.0 | Scenario Outline: Given the repository "" is cloned and checked out at the commit "". - When the argument --from-commit-hash is provided as "". + When the argument --from-commit-hash is provided as "". And the argument --from-version is provided as "". And the argument --current-version is provided as "". Then the current version assertion fails. Examples: - | repository | checkout_commit | from_commit_hash | from_version | current_version | + | repository | checkout_commit | commit_hash | from_version | current_version | | https://github.com/istanbuljs/istanbuljs.git | 1b52fe750d1f800c34dbff168614c0c73bd76026 | 5afe20347dd3ae954b31707a67f381f87920797f | 4.1.2 | 4.1.3 | | https://gitlab.com/dmfay/massive-js.git | 482c364acf5505b81c55245fac0472890d351662 | 3f20134864b19b11541287af440540c7ad0ed986 | 2.0.1 | 2.1.0 | Scenario Outline: When you provide an invalid commit hash a relevant error message is returned. Given the repository "" is cloned and checked out at the commit "". - When the argument --from-commit-hash is provided as "". + When the argument --from-commit-hash is provided as "". And the argument --from-version is provided as "". - Then their is a could not find commit hash "" error. + Then their is a could not find commit hash "" error. Examples: - | repository | checkout_commit | from_commit_hash | from_version | + | repository | checkout_commit | commit_hash | from_version | | https://github.com/SergioBenitez/Rocket.git | 549c9241c41320fc5af76b53c2ffc3bd8db88f8c | ecfc2c474575c6cdbc6d273c94c13181bd1dbaa6 | 1.0.4 | | https://github.com/electron/electron.git | 8798571a77a4d2a7e073b046d2e8b56caa4d1e68 | a115eaa633856eb0b09f4019952f866e6b4ef96d | 0.2.12 | | https://gitlab.com/gitlab-org/release-cli.git | 451e0773944e47a4e2678c67691a69cf8934e76e | 1260e8a74de5c29c85ffd4e2b91632236ea55c3a | 3.2.0 | \ No newline at end of file diff --git a/end-to-end-tests/features/from_reference.feature b/end-to-end-tests/features/from_reference.feature index a7c209e..da8826e 100644 --- a/end-to-end-tests/features/from_reference.feature +++ b/end-to-end-tests/features/from_reference.feature @@ -3,13 +3,13 @@ Feature: A Git reference can be provided as an argument to indicate where to sta Scenario Outline: Given the repository "" is cloned and checked out at the commit "". - When the argument --from-reference is provided as "". + When the argument --from-reference is provided as "". And the argument --from-version is provided as "". Then the returned version should be "". Examples: - | repository | checkout_commit | from_reference | from_version | expected_version | + | repository | checkout_commit | reference | from_version | expected_version | | https://github.com/yargs/yargs.git | 95a4a0ac573cfe158e6e4bc8c8682ebd1644a198 | v16.0.3 | 16.0.3 | 16.0.5 | @@ -35,11 +35,11 @@ Feature: A Git reference can be provided as an argument to indicate where to sta Scenario Outline: When you provide an invalid reference a relevant error message is returned. Given the repository "" is cloned and checked out at the commit "". - When the argument --from-reference is provided as "". + When the argument --from-reference is provided as "". And the argument --from-version is provided as "". - Then their is a could not find reference "" error. + Then their is a could not find reference "" error. Examples: - | repository | checkout_commit | from_reference | from_version | + | repository | checkout_commit | reference | from_version | | https://github.com/yargs/yargs.git | 95a4a0ac573cfe158e6e4bc8c8682ebd1644a198 | 16-0-3 | 16.0.3 | diff --git a/end-to-end-tests/features/from_shortened_commit_hash.feature b/end-to-end-tests/features/from_shortened_commit_hash.feature index 1d8c5c2..585b5bd 100644 --- a/end-to-end-tests/features/from_shortened_commit_hash.feature +++ b/end-to-end-tests/features/from_shortened_commit_hash.feature @@ -3,19 +3,19 @@ Feature: A shortened Git commit hash can be provided as an argument to indicate Scenario Outline: A shortened and full Git commit hash can be used interchangeably. Given the repository "" is cloned and checked out at the commit "". - When the argument --from-commit-hash is provided as "". + When the argument --from-commit-hash is provided as "". And the argument --from-version is provided as "". And the argument --calculation-mode is provided as "batch". Then the returned version should be "". Given the arguments are reset. - When the argument --from-commit-hash is provided as "". + When the argument --from-commit-hash is provided as "". And the argument --from-version is provided as "". And the argument --calculation-mode is provided as "batch". Then the returned version should be "". Examples: - | repository | checkout_commit | from_commit_hash | from_version | expected_version | shortened_from_commit_hash | + | repository | checkout_commit | commit_hash | from_version | expected_version | shortened_commit_hash | | https://github.com/yargs/yargs.git | 089417550ef5a5b8ce3578dd2a989191300b64cd | 262e796329f4a09083ca07e49f926ae43ac850e9 | 0.2.1 | 0.2.2 | 262e796 | | https://github.com/yargs/yargs.git | 027a6365b737e13116811a8ef43670196e1fa00a | 1f26de809432be9cc6f4f185629f6e5d13236598 | 0.2.3 | 0.3.0 | 1f26de8 | | https://github.com/danielduarte/diffparse | df6be23b79af66d3684fb27719020e1ce587f4b8 | 4f6bf53139fe66f61bd05893bcc9de6e96400c5c | 1.0.7 | 2.0.0 | 4f6bf53 | @@ -23,17 +23,17 @@ Feature: A shortened Git commit hash can be provided as an argument to indicate Scenario Outline: A shortened and full Git commit hash can be used interchangeably. Given the repository "" is cloned and checked out at the commit "". - When the argument --from-commit-hash is provided as "". + When the argument --from-commit-hash is provided as "". And the argument --from-version is provided as "". Then the returned version should be "". Given the arguments are reset. - When the argument --from-commit-hash is provided as "". + When the argument --from-commit-hash is provided as "". And the argument --from-version is provided as "". Then the returned version should be "". Examples: - | repository | checkout_commit | from_commit_hash | from_version | expected_version | shortened_from_commit_hash | + | repository | checkout_commit | commit_hash | from_version | expected_version | shortened_commit_hash | | https://github.com/yargs/yargs.git | 089417550ef5a5b8ce3578dd2a989191300b64cd | 262e796329f4a09083ca07e49f926ae43ac850e9 | 0.2.1 | 0.2.2 | 262e796 | | https://github.com/yargs/yargs.git | 6014e39bca3a1e8445aa0fb2a435f6181e344c45 | 705384762919641fe9d4c0967452a292f5f52c6d | 1.2.0 | 1.4.0 | 7053847 | | https://gitlab.com/dmfay/massive-js.git | 482c364acf5505b81c55245fac0472890d351662 | 3f20134864b19b11541287af440540c7ad0ed986 | 7.2.0 | 7.5.3 | 3f20134 | @@ -41,24 +41,24 @@ Feature: A shortened Git commit hash can be provided as an argument to indicate Scenario Outline: The shortened Git commit hash has no matches, so an error is returned. Given the repository "" is cloned and checked out at the commit "". - When the argument --from-commit-hash is provided as "". + When the argument --from-commit-hash is provided as "". And the argument --from-version is provided as "". - Then their is a could not find shortened commit hash "" error. + Then their is a could not find shortened commit hash "" error. Examples: - | repository | checkout_commit | from_shortened_commit_hash | from_version | + | repository | checkout_commit | shortened_commit_hash | from_version | | https://github.com/yargs/yargs.git | 089417550ef5a5b8ce3578dd2a989191300b64cd | 272a194 | 0.2.1 | | https://gitlab.com/dmfay/massive-js.git | 482c364acf5505b81c55245fac0472890d351662 | 3f235ee | 7.2.0 | Scenario Outline: The shortened Git commit hash is ambiguous as multiple commit hashes match it, so an error is returned. Given the repository "" is cloned and checked out at the commit "". - When the argument --from-commit-hash is provided as "". + When the argument --from-commit-hash is provided as "". And the argument --from-version is provided as "". - Then their is a ambiguous shortened commit hash "" error. + Then their is a ambiguous shortened commit hash "" error. Examples: - | repository | checkout_commit | from_shortened_commit_hash | from_version | + | repository | checkout_commit | shortened_commit_hash | from_version | | https://github.com/yargs/yargs.git | 089417550ef5a5b8ce3578dd2a989191300b64cd | 3f6 | 0.2.1 | diff --git a/end-to-end-tests/features/from_stdin.feature b/end-to-end-tests/features/from_stdin.feature index a252581..cb0ab12 100644 --- a/end-to-end-tests/features/from_stdin.feature +++ b/end-to-end-tests/features/from_stdin.feature @@ -4,12 +4,12 @@ Feature: A commit message can be provided by standard input rather than from a r Scenario Outline: Given the context and environment are reset. When the argument --from-version is provided as "". - And the flag --from-stdin is set and the standard input is "". + And the flag --from-stdin is set and the standard input is "". Then the returned version should be "". Examples: - | from_version | standard_input | expected_version | + | from_version | commit_message | expected_version | | 16.0.3 | "fix: removing GC mem leak" | 16.0.4 | | 0.0.3 | "feat: new from arg added" | 0.1.0 | | 1.2.0 | "feat!: changing from tag to reference" | 2.0.0 | diff --git a/end-to-end-tests/features/git_environment_variables.feature b/end-to-end-tests/features/git_environment_variables.feature index 3a1ea0d..aed7d00 100644 --- a/end-to-end-tests/features/git_environment_variables.feature +++ b/end-to-end-tests/features/git_environment_variables.feature @@ -3,7 +3,7 @@ Feature: Git environment variables are respected and used instead of using the c Scenario Outline: Given the repository "" is cloned and checked out at the commit "". - When the argument --from-commit-hash is provided as "". + When the argument --from-commit-hash is provided as "". And the argument --from-version is provided as "". And the argument --current-version is provided as "". Then the current version assertion passes. @@ -12,14 +12,14 @@ Feature: Git environment variables are respected and used instead of using the c Examples: - | repository | checkout_commit | from_commit_hash | from_version | current_version | + | repository | checkout_commit | commit_hash | from_version | current_version | | https://github.com/istanbuljs/istanbuljs.git | 1b52fe750d1f800c34dbff168614c0c73bd76026 | 5afe20347dd3ae954b31707a67f381f87920797f | 4.1.2 | 4.2.7 | | https://gitlab.com/dmfay/massive-js.git | 482c364acf5505b81c55245fac0472890d351662 | 3f20134864b19b11541287af440540c7ad0ed986 | 2.0.1 | 3.1.0 | Scenario Outline: Given the repository "" is cloned and checked out at the commit "". - When the argument --from-commit-hash is provided as "". + When the argument --from-commit-hash is provided as "". And the argument --from-version is provided as "". And the argument --current-version is provided as "". Then the current version assertion fails. @@ -28,14 +28,14 @@ Feature: Git environment variables are respected and used instead of using the c Examples: - | repository | checkout_commit | from_commit_hash | from_version | current_version | + | repository | checkout_commit | commit_hash | from_version | current_version | | https://github.com/istanbuljs/istanbuljs.git | 1b52fe750d1f800c34dbff168614c0c73bd76026 | 5afe20347dd3ae954b31707a67f381f87920797f | 4.1.2 | 4.1.3 | | https://gitlab.com/dmfay/massive-js.git | 482c364acf5505b81c55245fac0472890d351662 | 3f20134864b19b11541287af440540c7ad0ed986 | 2.0.1 | 2.1.0 | Scenario Outline: Given the repository "" is cloned and checked out at the commit "". - When the argument --from-reference is provided as "". + When the argument --from-reference is provided as "". And the argument --from-version is provided as "". Then the returned version should be "". Given the GIT_DIR environment variable is set to the cloned repository. @@ -43,13 +43,13 @@ Feature: Git environment variables are respected and used instead of using the c Examples: - | repository | checkout_commit | from_reference | from_version | expected_version | + | repository | checkout_commit | reference | from_version | expected_version | | https://github.com/yargs/yargs.git | 95a4a0ac573cfe158e6e4bc8c8682ebd1644a198 | v16.0.3 | 16.0.3 | 16.0.5 | Scenario Outline: You can also provide the long name and partial names not just the short name. Given the repository "" is cloned and checked out at the commit "". - When the argument --from-reference is provided as "". + When the argument --from-reference is provided as "". And the argument --from-version is provided as "". Then the returned version should be "". Given the GIT_DIR environment variable is set to the cloned repository. @@ -57,6 +57,6 @@ Feature: Git environment variables are respected and used instead of using the c Examples: - | repository | checkout_commit | from_reference | from_version | expected_version | + | repository | checkout_commit | reference | from_version | expected_version | | https://github.com/Netflix/unleash.git | 238ce019c3a7b3302721fc1ae5b8ad2bdd50a706 | refs/tags/v2.0.0 | 2.0.0 | 2.0.1 | | https://github.com/Netflix/unleash.git | 238ce019c3a7b3302721fc1ae5b8ad2bdd50a706 | tags/v2.0.0 | 2.0.0 | 2.0.1 | diff --git a/end-to-end-tests/features/history_mode.feature b/end-to-end-tests/features/history_mode.feature index 765436c..6970459 100644 --- a/end-to-end-tests/features/history_mode.feature +++ b/end-to-end-tests/features/history_mode.feature @@ -3,7 +3,7 @@ Feature: Specifies how commits are parsed, acceptable values are 'first' to pars Scenario Outline: All the parents of merge commit's are parsed for their Git commit messages. Given the repository "" is cloned and checked out at the commit "". - When the argument --from-commit-hash is provided as "". + When the argument --from-commit-hash is provided as "". And the argument --from-version is provided as "". Then the returned version should be "". When the argument --history-mode is provided as "all". @@ -11,30 +11,30 @@ Feature: Specifies how commits are parsed, acceptable values are 'first' to pars Examples: - | repository | checkout_commit | from_commit_hash | from_version | default_expected_version | all_parents_expected_version | + | repository | checkout_commit | commit_hash | from_version | default_expected_version | all_parents_expected_version | | https://github.com/dcyou/resume.git | 9015044aba82dbe8aa0119bffd7ea73cad171dd0 | fe14480df04f76e6434d45c762ab087df41b8473 | 1.2.2 | 1.3.1 | 1.3.30 | Scenario Outline: Only the first parent of merge commit's are parsed for their Git commit messages. Given the repository "" is cloned and checked out at the commit "". - When the argument --from-commit-hash is provided as "". + When the argument --from-commit-hash is provided as "". And the argument --from-version is provided as "". And the argument --history-mode is provided as "first". Then the returned version should be "". Examples: - | repository | checkout_commit | from_commit_hash | from_version | expected_version | + | repository | checkout_commit | commit_hash | from_version | expected_version | | https://github.com/dcyou/resume.git | 9015044aba82dbe8aa0119bffd7ea73cad171dd0 | fe14480df04f76e6434d45c762ab087df41b8473 | 1.2.2 | 1.3.1 | Scenario Outline: Only the first parent of merge commit's are parsed for their Git commit messages, by default. Given the repository "" is cloned and checked out at the commit "". - When the argument --from-commit-hash is provided as "". + When the argument --from-commit-hash is provided as "". And the argument --from-version is provided as "". Then the returned version should be "". Examples: - | repository | checkout_commit | from_commit_hash | from_version | expected_version | + | repository | checkout_commit | commit_hash | from_version | expected_version | | https://github.com/dcyou/resume.git | 9015044aba82dbe8aa0119bffd7ea73cad171dd0 | fe14480df04f76e6434d45c762ab087df41b8473 | 1.2.2 | 1.3.1 | diff --git a/end-to-end-tests/features/monorepo.feature b/end-to-end-tests/features/monorepo.feature index 58f0e88..37a6004 100644 --- a/end-to-end-tests/features/monorepo.feature +++ b/end-to-end-tests/features/monorepo.feature @@ -3,33 +3,33 @@ Feature: The next semantic version is calculated only from commits altering file Scenario Outline: Given the repository "" is cloned and checked out at the commit "". - When the argument --from-commit-hash is provided as "". + When the argument --from-commit-hash is provided as "". And the argument --from-version is provided as "". Then the returned version should be "". Given the arguments are reset. - When the argument --from-commit-hash is provided as "". + When the argument --from-commit-hash is provided as "". And the argument --from-version is provided as "". And the argument --monorepo is provided as "". Then the returned version should be "". Examples: - | repository | checkout_commit | from_commit_hash | from_version | expected_version | monorepo | monorepo_expected_version | + | repository | checkout_commit | commit_hash | from_version | expected_version | monorepo | monorepo_expected_version | | https://github.com/yargs/yargs.git | acff16db1057ea830a37f2214782e5026be894b6 | cb01c98c44e30f55c2dc9434caef524ae433d9a4 | 1.7.2 | 1.8.0 | helpers/ | 1.7.3 | | https://github.com/istanbuljs/istanbuljs.git | 1b52fe750d1f800c34dbff168614c0c73bd76026 | df24342395030dc2a40a7ceb0476a9897f3492a3 | 3.0.1 | 3.0.5 | packages/istanbul-reports/test/ | 3.0.2 | Scenario Outline: Given the repository "" is cloned and checked out at the commit "". - When the argument --from-commit-hash is provided as "". + When the argument --from-commit-hash is provided as "". And the argument --from-version is provided as "". Then the returned version should be "". Given the arguments are reset. - When the argument --from-commit-hash is provided as "". + When the argument --from-commit-hash is provided as "". And the argument --from-version is provided as "". And the argument --monorepo is provided as "". And the argument --monorepo is provided as "". Then the returned version should be "". Examples: - | repository | checkout_commit | from_commit_hash | from_version | expected_version | monorepo_1 | monorepo_2 | monorepo_expected_version | + | repository | checkout_commit | commit_hash | from_version | expected_version | monorepo_1 | monorepo_2 | monorepo_expected_version | | https://github.com/yargs/yargs.git | acff16db1057ea830a37f2214782e5026be894b6 | cb01c98c44e30f55c2dc9434caef524ae433d9a4 | 1.7.2 | 1.8.0 | helpers/ | package.json | 1.7.4 | diff --git a/end-to-end-tests/features/pre_major_release.feature b/end-to-end-tests/features/pre_major_release.feature index 7068bc6..df20b94 100644 --- a/end-to-end-tests/features/pre_major_release.feature +++ b/end-to-end-tests/features/pre_major_release.feature @@ -3,33 +3,33 @@ Feature: Breaking changes for pre-major release semantic versions only increment Scenario Outline: Given the repository "" is cloned and checked out at the commit "". - When the argument --from-commit-hash is provided as "". + When the argument --from-commit-hash is provided as "". And the argument --from-version is provided as "". And the argument --calculation-mode is provided as "batch". Then the returned version should be "". Given the arguments are reset. - When the argument --from-commit-hash is provided as "". + When the argument --from-commit-hash is provided as "". And the argument --from-version is provided as "". And the argument --calculation-mode is provided as "batch". Then the returned version should be "". Examples: - | repository | checkout_commit | from_commit_hash | post_major_release_from_version | post_major_release_expected_version | pre_major_release_from_version | pre_major_release_expected_version | + | repository | checkout_commit | commit_hash | post_major_release_from_version | post_major_release_expected_version | pre_major_release_from_version | pre_major_release_expected_version | | https://github.com/yargs/yargs.git | 089417550ef5a5b8ce3578dd2a989191300b64cd | 262e796329f4a09083ca07e49f926ae43ac850e9 | 1.3.0 | 1.3.1 | 0.2.1 | 0.2.2 | | https://github.com/yargs/yargs.git | b6286d7269f3b20fd00da6e7326d3852a162deea | 395bb67749787d269cabe80ffc3133c2f6958aeb | 1.0.7 | 2.0.0 | 0.2.1 | 0.3.0 | Scenario Outline: Given the repository "" is cloned and checked out at the commit "". - When the argument --from-commit-hash is provided as "". + When the argument --from-commit-hash is provided as "". And the argument --from-version is provided as "". Then the returned version should be "". Given the arguments are reset. - When the argument --from-commit-hash is provided as "". + When the argument --from-commit-hash is provided as "". And the argument --from-version is provided as "". Then the returned version should be "". Examples: - | repository | checkout_commit | from_commit_hash | post_major_release_from_version | post_major_release_expected_version | pre_major_release_from_version | pre_major_release_expected_version | + | repository | checkout_commit | commit_hash | post_major_release_from_version | post_major_release_expected_version | pre_major_release_from_version | pre_major_release_expected_version | | https://github.com/yargs/yargs.git | 089417550ef5a5b8ce3578dd2a989191300b64cd | 262e796329f4a09083ca07e49f926ae43ac850e9 | 1.3.0 | 1.3.1 | 0.2.1 | 0.2.2 | | https://github.com/yargs/yargs.git | b6286d7269f3b20fd00da6e7326d3852a162deea | 395bb67749787d269cabe80ffc3133c2f6958aeb | 1.0.7 | 2.0.2 | 0.2.1 | 0.3.2 | diff --git a/end-to-end-tests/features/steps/given.py b/end-to-end-tests/features/steps/given.py index d568a86..054a26c 100644 --- a/end-to-end-tests/features/steps/given.py +++ b/end-to-end-tests/features/steps/given.py @@ -9,6 +9,7 @@ @given('the arguments are reset.') def reset_arguments(context): context.arguments = "" + context.from_ref = "" @given('the context and environment are reset.') diff --git a/end-to-end-tests/features/steps/then.py b/end-to-end-tests/features/steps/then.py index a15e944..6b225ce 100644 --- a/end-to-end-tests/features/steps/then.py +++ b/end-to-end-tests/features/steps/then.py @@ -79,7 +79,7 @@ def assert_could_not_find_shortened_commit_hash_error(context, shortened_commit_ @then('their is a ambiguous shortened commit hash "{shortened_commit_hash}" error.') def assert_ambiguous_shortened_commit_hash_error(context, shortened_commit_hash): # Given - ambiguous_shortened_commit_hash_error = re.compile(f"^ ERROR conventional_commits_next_version > Ambiguous short commit hash, the commit hashes [[]({shortened_commit_hash}[a-f0-9]*(, )?)*[]] all start with the provided short commit hash \"{shortened_commit_hash}\".\n$") # fmt: off + ambiguous_shortened_commit_hash_error = re.compile(f"^ ERROR conventional_commits_next_version > Could not find a reference with the name \"{shortened_commit_hash}\".\n\nCaused by:\n Ambiguous short commit hash, the commit hashes [[]({shortened_commit_hash}[a-f0-9]*(, )?)*[]] all start with the provided short commit hash \"{shortened_commit_hash}\".\n$") # fmt: off # When/Then result = assert_current_version_assertion_fails(context) @@ -91,34 +91,10 @@ def assert_ambiguous_shortened_commit_hash_error(context, shortened_commit_hash) @then('their is a missing from argument error.') def assert_missing_from_argument_error(context): # Given - missing_from_argument_error = "error: the following required arguments were not provided:\n <--from-stdin|--from-reference |--from-commit-hash >\n\nUsage: conventional_commits_next_version --from-version <--from-stdin|--from-reference |--from-commit-hash >\n\nFor more information, try '--help'.\n" + missing_from_argument_error = "error: the following required arguments were not provided:\n \n\nUsage: conventional_commits_next_version --from-version \n\nFor more information, try '--help'.\n" # When/Then result = assert_current_version_assertion_fails(context) # Then assert_error_equals(result, missing_from_argument_error) - - -@then('their is a conflicting from arguments error.') -def assert_conflicting_from_arguments_error(context): - # Given - conflicting_from_commit_hash_from_reference_error = "error: the argument '--from-commit-hash ' cannot be used with '--from-reference '\n\nUsage: conventional_commits_next_version --from-version <--from-stdin|--from-reference |--from-commit-hash >\n\nFor more information, try '--help'.\n" - conflicting_from_commit_hash_from_stdin_error = "error: the argument '--from-commit-hash ' cannot be used with '--from-stdin'\n\nUsage: conventional_commits_next_version --from-version <--from-stdin|--from-reference |--from-commit-hash >\n\nFor more information, try '--help'.\n" - conflicting_from_reference_from_commit_hash_error = "error: the argument '--from-reference ' cannot be used with '--from-commit-hash '\n\nUsage: conventional_commits_next_version --from-version <--from-stdin|--from-reference |--from-commit-hash >\n\nFor more information, try '--help'.\n" - conflicting_from_reference_from_stdin_error = "error: the argument '--from-reference ' cannot be used with '--from-stdin'\n\nUsage: conventional_commits_next_version --from-version <--from-stdin|--from-reference |--from-commit-hash >\n\nFor more information, try '--help'.\n" - conflicting_from_stdin_from_commit_hash_error = "error: the argument '--from-stdin' cannot be used with '--from-commit-hash '\n\nUsage: conventional_commits_next_version --from-version <--from-stdin|--from-reference |--from-commit-hash >\n\nFor more information, try '--help'.\n" - conflicting_from_stdin_from_reference_error = "error: the argument '--from-stdin' cannot be used with '--from-reference '\n\nUsage: conventional_commits_next_version --from-version <--from-stdin|--from-reference |--from-commit-hash >\n\nFor more information, try '--help'.\n" - - # When/Then - result = assert_current_version_assertion_fails(context) - - # Then - assert_error_is_one_of(result, [ - conflicting_from_commit_hash_from_reference_error, - conflicting_from_commit_hash_from_stdin_error, - conflicting_from_reference_from_commit_hash_error, - conflicting_from_reference_from_stdin_error, - conflicting_from_stdin_from_commit_hash_error, - conflicting_from_stdin_from_reference_error, - ]) diff --git a/end-to-end-tests/features/steps/utilities.py b/end-to-end-tests/features/steps/utilities.py index b3e82a0..cdbdc4a 100644 --- a/end-to-end-tests/features/steps/utilities.py +++ b/end-to-end-tests/features/steps/utilities.py @@ -29,7 +29,8 @@ def execute_conventional_commits_next_version(context): result = execute_command( context.pre_command + context.conventional_commits_next_version_path + - context.arguments) + context.arguments + + context.from_ref) if "GIT_DIR" not in os.environ: os.chdir(context.behave_directory) diff --git a/end-to-end-tests/features/steps/when.py b/end-to-end-tests/features/steps/when.py index 7b3cc41..f850905 100644 --- a/end-to-end-tests/features/steps/when.py +++ b/end-to-end-tests/features/steps/when.py @@ -6,7 +6,7 @@ def set_from_stdin(context, standard_input): context.standard_input = standard_input.strip() context.pre_command = f"echo -e {context.standard_input} | " - context.arguments += " --from-stdin " + context.from_ref = " \"-\"" # Testing we can use stdin when not in a Git repository. # https://gitlab.com/DeveloperC/conventional_commits_linter/-/issues/3 context.remote_repository_cache = tempfile.mkdtemp() @@ -14,12 +14,12 @@ def set_from_stdin(context, standard_input): @when('the argument --from-reference is provided as "{from_reference}".') def set_from_reference(context, from_reference): - context.arguments += f" --from-reference {from_reference} " + context.from_ref = f" \"{from_reference}\"" @when('the argument --from-commit-hash is provided as "{from_commit_hash}".') def set_from_commit_hash(context, from_commit_hash): - context.arguments += f" --from-commit-hash {from_commit_hash} " + context.from_ref = f" \"{from_commit_hash}\"" @when('the argument --monorepo is provided as "{monorepo}".') diff --git a/end-to-end-tests/features/v_prefix_ignored.feature b/end-to-end-tests/features/v_prefix_ignored.feature index 28e61c9..08e494c 100644 --- a/end-to-end-tests/features/v_prefix_ignored.feature +++ b/end-to-end-tests/features/v_prefix_ignored.feature @@ -3,13 +3,13 @@ Feature: The semantic version if prefixed with a v is supported and can still be Scenario Outline: Given the repository "" is cloned and checked out at the commit "". - When the argument --from-commit-hash is provided as "". + When the argument --from-commit-hash is provided as "". And the argument --from-version is provided as "". Then the returned version should be "". Examples: - | repository | checkout_commit | from_commit_hash | from_version | expected_version | + | repository | checkout_commit | commit_hash | from_version | expected_version | | https://github.com/yargs/yargs.git | 089417550ef5a5b8ce3578dd2a989191300b64cd | 262e796329f4a09083ca07e49f926ae43ac850e9 | v0.2.1 | 0.2.2 | | https://github.com/istanbuljs/istanbuljs.git | 1b52fe750d1f800c34dbff168614c0c73bd76026 | c4f276e26455dc96705a49e7651e86a2345724ec | V1.0.4 | 1.0.5 | | https://github.com/BlazeSoftware/atoms.git | 987956d91c24ae56b7198bbb527f45a88f69fcda | 2a174d6121a4f3f27d3782c3d35218d990b008df | V9.2.3 | 9.3.2 | \ No newline at end of file diff --git a/src/cli/mod.rs b/src/cli/mod.rs index 915db9f..7f8050b 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -1,4 +1,4 @@ -use clap::{ArgGroup, Parser}; +use clap::Parser; use semver::{Error, Version}; pub use crate::calculation_mode::CalculationMode; @@ -6,32 +6,7 @@ pub use crate::history_mode::HistoryMode; #[derive(Parser, Debug)] #[command(author, version, about, long_about = None)] -#[clap(group( - ArgGroup::new("from") - .required(true) -))] pub(crate) struct Arguments { - #[arg( - long, - group = "from", - help = "The singular Git commit message to use in the calculation of the next semantic version." - )] - pub(crate) from_stdin: bool, - - #[arg( - long, - group = "from", - help = "The Git reference from where to start taking the range of commits from till HEAD. The range is inclusive of HEAD and exclusive of the provided reference." - )] - pub(crate) from_reference: Option, - - #[arg( - long, - group = "from", - help = "The Git commit hash from where to start taking the range of commits from till HEAD. The range is inclusive of HEAD and exclusive of the provided Git commit hash." - )] - pub(crate) from_commit_hash: Option, - #[arg( long, help = "The the next semantic version is calculated only from commits altering files which match any of these provided regexes, enabling usage within monorepos." @@ -65,6 +40,11 @@ pub(crate) struct Arguments { help = "This semantic version is asserted to be equal or larger than the calculated semantic version. The calculated semantic version is not printed to standard out. If the assertion is not met then it exits with a non zero exit code." )] pub(crate) current_version: Option, + + #[arg( + help = "The Git reference from where to start taking the range of commits from till HEAD to lint. The range is inclusive of HEAD and exclusive of the provided reference. '-' indicates to read the standard input and lint the input as a Git commit message." + )] + pub(crate) from: String, } fn parse_version(src: &str) -> Result { diff --git a/src/commits/mod.rs b/src/commits/mod.rs index 15294ef..ead9334 100644 --- a/src/commits/mod.rs +++ b/src/commits/mod.rs @@ -23,24 +23,17 @@ impl Commits { } } - pub fn from_reference>( + pub fn from_git>( repository: &Repository, - reference: T, + git: T, commit_filters: Vec, history_mode: HistoryMode, ) -> Result { - let reference_oid = get_reference_oid(repository, reference.as_ref())?; - get_commits_till_head_from_oid(repository, reference_oid, commit_filters, history_mode) - } + let oid = parse_to_oid(repository, git.as_ref()).or_else(|error| { + get_reference_oid(repository, git.as_ref()).map_err(|e| error.context(e)) + })?; - pub fn from_commit_hash>( - repository: &Repository, - commit_hash: T, - commit_filters: Vec, - history_mode: HistoryMode, - ) -> Result { - let commit_oid = parse_to_oid(repository, commit_hash.as_ref())?; - get_commits_till_head_from_oid(repository, commit_oid, commit_filters, history_mode) + get_commits_till_head_from_oid(repository, oid, commit_filters, history_mode) } pub fn get_next_version( @@ -219,10 +212,7 @@ fn parse_to_oid(repository: &Repository, oid: &str) -> Result { None } - Err(error) => { - error!("{:?}", error); - None - } + Err(_) => None, }) .collect(); diff --git a/src/main.rs b/src/main.rs index ce8b75a..65ac7b3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -33,39 +33,21 @@ fn main() { } fn run(arguments: Arguments) -> Result<()> { - let commits = match ( - arguments.from_stdin, - arguments.from_commit_hash, - arguments.from_reference, - ) { - (true, None, None) => { - let mut commit_message = String::new(); - stdin().read_to_string(&mut commit_message).unwrap(); + let commits = if arguments.from == "-" { + let mut commit_message = String::new(); + stdin().read_to_string(&mut commit_message).unwrap(); - Ok(Commits::from_commit_message(commit_message)) - } - (false, Some(from_commit_hash), None) => { - let repository = Repository::open_from_env()?; - Commits::from_commit_hash( - &repository, - from_commit_hash, - arguments.monorepo, - arguments.history_mode, - ) - } - (false, None, Some(from_reference)) => { - let repository = Repository::open_from_env()?; - Commits::from_reference( - &repository, - from_reference, - arguments.monorepo, - arguments.history_mode, - ) - } - (_, _, _) => { - bail!("Invalid combination of arguments."); - } + Ok(Commits::from_commit_message(commit_message)) + } else { + let repository = Repository::open_from_env()?; + Commits::from_git( + &repository, + arguments.from, + arguments.monorepo, + arguments.history_mode, + ) }?; + let expected_version = commits.get_next_version(arguments.from_version, arguments.calculation_mode);