Skip to content
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

WIP: git hooks support and run tests before push #14

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .git-hooks/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

npm run prepush --quiet
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.git-hooks/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This package can be imported as a library, exposing the function `readResources`

Alternatively, `npm run build` will write all resources to `dist/resources.json` for future use.

Use `npm run verify` after modifying the resources or metadata file to ensure the format can be accepted by `adblock-rust`.
Use `npm test` after modifying the resources or metadata file to ensure the format can be accepted by `adblock-rust`.
myreli marked this conversation as resolved.
Show resolved Hide resolved

## Metadata format

Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"main": "index.js",
"scripts": {
"build": "node build",
"test": "node verify"
"test": "node verify",
"prepush": "npm run test",
"postinstall": "if [ -d .git-hooks ]; then for file in `ls .git-hooks`; do ln -sf ../../.git-hooks/${file} .git/hooks/${file}; done fi"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're checking that .git-hooks is a directory, we should probably also check that .git/hooks is a directory.

Copy link
Author

@myreli myreli Feb 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, we are checking for the .git-hooks directory just to find out if we should install the customized hooks. Since this directory is ignored when the library is installed, we won't be installing and executing our hooks in the consumer projects.

As for the .git/hooks I have assumed that the project is always initialized as .git repository, do you think it makes sense to change this behaviour?

},
"repository": {
"type": "git",
Expand Down