-
Notifications
You must be signed in to change notification settings - Fork 10
feat(ci): add --config option and MERGIFY_CONFIG_PATH envvar to git-refs and scopes #1000
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -218,7 +218,8 @@ def git_refs() -> None: | |
| @click.option( | ||
| "--config", | ||
| "config_path", | ||
| type=click.Path(), | ||
| type=click.Path(exists=True, dir_okay=False), | ||
| envvar="MERGIFY_CONFIG_PATH", | ||
| default=detector.get_mergify_config_path, | ||
| help="Path to YAML config file.", | ||
|
Comment on lines
218
to
224
|
||
| ) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -490,6 +490,25 @@ def test_scopes_send( | |
| assert sorted(payload["scopes"]) == ["backend", "foobar", "frontend"] | ||
|
|
||
|
|
||
| def test_scopes_empty_mergify_config_env_uses_autodetection( | ||
| tmp_path: pathlib.Path, | ||
| monkeypatch: pytest.MonkeyPatch, | ||
| ) -> None: | ||
| """When MERGIFY_CONFIG_PATH is set but empty, the config should be auto-detected.""" | ||
| config_file = tmp_path / ".mergify.yml" | ||
| config_file.write_text("scopes:\n source:\n manual:\n") | ||
|
|
||
| monkeypatch.chdir(tmp_path) | ||
| monkeypatch.setenv("MERGIFY_CONFIG_PATH", "") | ||
|
|
||
| runner = testing.CliRunner() | ||
| result = runner.invoke(ci_cli.scopes, ["--base", "old", "--head", "new"]) | ||
|
|
||
| # The command found the auto-detected config and ran (source is manual so exit 1) | ||
| assert result.exit_code == 1 | ||
| assert "source `manual` has been set" in result.output | ||
|
Comment on lines
+501
to
+509
|
||
|
|
||
|
|
||
| def test_git_refs( | ||
| tmp_path: pathlib.Path, | ||
| monkeypatch: pytest.MonkeyPatch, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MERGIFY_CONFIG_PATHset to an empty string will be treated by Click as an explicit option value, and withclick.Path(exists=True, dir_okay=False)it will fail parameter validation (exit code 2) beforedefault=get_mergify_config_pathcan run. This prevents the intended “empty env var => autodetect” behavior (and makes the new test fail). Consider either removingexists=Trueand validating existence insidescopes()only when a non-empty path is provided, or adding logic to treat an empty envvar value as unset before Click performs path validation.