Repository navigation
fix(integrations): keep shared scripts executable when the default integration changes #5425
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
Merged
mnriem
merged 6 commits into
github:main
from
kartsan03:fix/keep-scripts-executable-on-default-change
Nov 18, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
89bea99
fix(integrations): keep shared scripts executable when the default in…
kartsan03 13ff151
fix(integrations): set shared script execute bits in the refresh's ow…
kartsan03 3f7bdc0
test(integrations): cover the shared script mode rule and its rollback
kartsan03 b5b100f
test(integrations): check the owner execute bit in the rollback test
kartsan03 1ae9c47
test(integrations): serve the shared scripts at 0644 in the mode tests
kartsan03 b43008b
fix(integrations): keep the mode of a shared script that is already e…
kartsan03 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| """Unit tests for the mode shared scripts are written with.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import os | ||
|
|
||
| import pytest | ||
|
|
||
| from specify_cli import shared_infra | ||
| from specify_cli.shared_infra import _shared_script_mode | ||
|
|
||
| SHEBANG = b"#!/usr/bin/env bash\necho hi\n" | ||
|
|
||
|
|
||
| def _source(tmp_path, name, mode): | ||
| path = tmp_path / name | ||
| path.write_bytes(SHEBANG) | ||
| path.chmod(mode) | ||
| return path | ||
|
|
||
|
|
||
| @pytest.mark.skipif(os.name == "nt", reason="POSIX execute bits are not meaningful on Windows") | ||
| @pytest.mark.parametrize( | ||
| ("source_mode", "expected"), | ||
| [(0o644, 0o755), (0o640, 0o750), (0o600, 0o700), (0o200, 0o300)], | ||
| ) | ||
| def test_shell_script_gets_execute_bit_for_each_class_that_reads(tmp_path, source_mode, expected): | ||
| source = _source(tmp_path, "setup-plan.sh", source_mode) | ||
| assert _shared_script_mode(source, SHEBANG) == expected | ||
|
|
||
|
|
||
| @pytest.mark.skipif(os.name == "nt", reason="POSIX execute bits are not meaningful on Windows") | ||
| @pytest.mark.parametrize("source_mode", [0o755, 0o744, 0o754, 0o700, 0o710]) | ||
| def test_already_executable_script_keeps_its_mode(tmp_path, source_mode): | ||
| source = _source(tmp_path, "setup-plan.sh", source_mode) | ||
| assert _shared_script_mode(source, SHEBANG) == source_mode | ||
|
|
||
|
|
||
| @pytest.mark.skipif(os.name == "nt", reason="POSIX execute bits are not meaningful on Windows") | ||
| @pytest.mark.parametrize( | ||
| ("name", "content"), | ||
| [ | ||
| ("common.sh", b"echo sourced, no shebang\n"), | ||
| ("common.sh", b""), | ||
| ("setup-plan.ps1", SHEBANG), | ||
| ("setup_plan.py", SHEBANG), | ||
| ("sh", SHEBANG), | ||
| ], | ||
| ) | ||
| def test_other_files_keep_the_packaged_mode(tmp_path, name, content): | ||
| source = _source(tmp_path, name, 0o644) | ||
| assert _shared_script_mode(source, content) == 0o644 | ||
|
|
||
|
|
||
| def test_windows_keeps_the_packaged_mode(tmp_path, monkeypatch): | ||
| source = _source(tmp_path, "setup-plan.sh", 0o644) | ||
| packaged = source.stat().st_mode & 0o777 | ||
| monkeypatch.setattr(shared_infra.os, "name", "nt") | ||
| assert _shared_script_mode(source, SHEBANG) == packaged |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.