Skip to content

Commit

Permalink
feat(validation): add option to exclude a list of commits by sha
Browse files Browse the repository at this point in the history
This adds a new configuration option, `excluded-commits`, which allows
the user to provide a list of commits (full SHA1; 40 characters) that
will be skipped during validation runs.

This is useful for instance when having to merge branches from other,
less strictly checked repo's.
  • Loading branch information
jstmlr committed Jun 22, 2023
1 parent 420729f commit 44cb577
Show file tree
Hide file tree
Showing 10 changed files with 502 additions and 8 deletions.
95 changes: 94 additions & 1 deletion dist/bump/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions dist/cli/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

95 changes: 94 additions & 1 deletion dist/validate/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ initial-development: false # OPTIONAL, defaults to `true`
| `allowed-branches` | `.*` | A regex specifying from which branch(es) releases and Git tags are allowed to be created |
| `initial-development` | `true` | A boolean indicating that this project is still under _initial development_. During this state, any commit message containing a breaking change will result in a `MINOR` version bump. |
| `sdkver-create-release-branches` | `false` | For SdkVer versioning scheme only: push a new branch if an RC or release build is performed on a non-release branch. If this config value is boolean `true`, the branch shall be of the form `release/N.N`. If this value is set to a string, it shall be used as the branch name prefix and appended with the major and minor release numbers, e.g. config value `"rel/"` results in a branch named `rel/N.N`. |
| `excluded-commits` | `[]` | An optional list of (40-character) SHA1 hashes representing commits (and their ancestry) that should not be checked. For example, when merging another repo/branch with non-conventional-commits, add the SHA of that repo/branch's HEAD to the list, which allows it to pass the validation action. |

> :bulb: By default `commisery-action` will search for the file `.commisery.yml`.
You can specify a different file with the `config` input parameter.
21 changes: 21 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const CONFIG_ITEMS = [
"release-branches",
"prereleases",
"sdkver-create-release-branches",
"excluded-commits",
];

const VERSION_SCHEMES = ["semver", "sdkver"];
Expand Down Expand Up @@ -107,6 +108,7 @@ export class Configuration {
tags: IConfigurationRules = DEFAULT_ACCEPTED_TAGS;
rules: Map<string, IRuleConfigItem> = new Map<string, IRuleConfigItem>();
sdkverCreateReleaseBranches?: string = undefined;
excludedCommits: string[] = [];

set initialDevelopment(initialDevelopment: boolean) {
this._initialDevelopment = initialDevelopment;
Expand Down Expand Up @@ -339,6 +341,25 @@ export class Configuration {
);
}
break;

case "excluded-commits":
/* Example YAML:
* excluded-commits: []
* excluded-commits: ["3723ac94f5091257195d91a26e03492a8265b90d"]
* excluded-commits:
* - 3723ac94f5091257195d91a26e03492a8265b90d
* - 1234567890123456789012345678901234567890
*/
if (typeof data[key] === "object") {
this.excludedCommits = data[key] as string[];
} else {
throw new Error(
`Incorrect type '${typeof data[
key
]}' for '${key}', must be an array of strings!`
);
}
break;
}
}
if (
Expand Down
Loading

0 comments on commit 44cb577

Please sign in to comment.