-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: secureli 372 fix init when no pre-commit-config exists (#502)
secureli-XXX in a final check on recent work, I noticed that init was failing if there was no .pre-commit-config.yaml. This should fix that issue, maintain new functionality for copying existing yaml settings, and update tests. ## Changes * Updated action, language_support, and pre_commit to account for a lack of a .pre-commit-config.yaml by creating blank one if it doesn't exist. If it does exist and isn't where we want it, we move it. ## Testing * all tests pass * in a dummy repo, run secureli init _with_ a .pre-commit-config.yaml in the root directory * in a dummy repo, run secureli init _without_ a .pre-commit-config.yaml in the root directory ## Clean Code Checklist <!-- This is here to support you. Some/most checkboxes may not apply to your change --> - [x] Meets acceptance criteria for issue - [x] New logic is covered with automated tests - [ ] Appropriate exception handling added - [ ] Thoughtful logging included - [ ] Documentation is updated - [ ] Follow-up work is documented in TODOs - [x] TODOs have a ticket associated with them - [x] No commented-out code included --------- Co-authored-by: Jordan Heffernan <[email protected]>
- Loading branch information
1 parent
f7708ef
commit f262cde
Showing
7 changed files
with
109 additions
and
32 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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,22 @@ | ||
# Test to ensure pre-exisiting hooks within the .pre-commit-config.yaml files | ||
# are persisted when installing secureli | ||
|
||
MOCK_REPO='tests/test-data/mock-repo' | ||
|
||
setup() { | ||
load "${BATS_LIBS_ROOT}/bats-support/load" | ||
load "${BATS_LIBS_ROOT}/bats-assert/load" | ||
mkdir -p $MOCK_REPO | ||
echo 'print("hello world!")' > $MOCK_REPO/hw.py | ||
run git init $MOCK_REPO | ||
} | ||
|
||
@test "can preserve pre-existing hooks" { | ||
run python secureli/main.py init -y --directory $MOCK_REPO | ||
run grep 'https://github.com/psf/black' $MOCK_REPO/.secureli/.pre-commit-config.yaml | ||
assert_output --partial 'https://github.com/psf/black' | ||
} | ||
|
||
teardown() { | ||
rm -rf $MOCK_REPO | ||
} |
This file contains 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 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