-
Notifications
You must be signed in to change notification settings - Fork 18
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
Implement universal Git hooks integration #184
base: main
Are you sure you want to change the base?
Implement universal Git hooks integration #184
Conversation
@@ -0,0 +1,108 @@ | |||
|
|||
import { parse } from "https://deno.land/std/flags/mod.ts"; |
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.
Be sure to turn on Deno linting in VS Code, it will remind you that this is not a proper way to reference imports. You should use pinned versions.
@@ -0,0 +1,108 @@ | |||
|
|||
import { parse } from "https://deno.land/std/flags/mod.ts"; | |||
import { Command } from "https://deno.land/x/cliffy/command/mod.ts"; |
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.
Be sure to turn on Deno linting in VS Code, it will remind you that this is not a proper way to reference imports. You should use pinned versions.
|
||
for (const [name, handler] of Object.entries(hooks)) { | ||
const script = `#!/usr/bin/env -S deno run --allow-read --allow-write --allow-env | ||
import { ${name} } from "https://raw.githubusercontent.com/netspective-labs/sql-aide/vX.Y.Z/lib/universal/git-hooks.ts"; |
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.
vX.Y.Z
will fail every time.
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.
This means you gave me a PR without local testing. Please never do that again.
import { parse } from "https://deno.land/std/flags/mod.ts"; | ||
import { Command } from "https://deno.land/x/cliffy/command/mod.ts"; | ||
|
||
async function initHooks() { |
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.
add default args like:
initHooks(gitHooksPath = path.join(Deno.cwd(), '.githooks') )
Include anything else that might be optional.
import { ${name} } from "https://raw.githubusercontent.com/netspective-labs/sql-aide/vX.Y.Z/lib/universal/git-hooks.ts"; | ||
await ${name}();`; | ||
|
||
await Deno.writeTextFile(`${gitHooksDir}/${name}`, script, { mode: 0o755 }); |
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.
use Deno stdlib path
module and path.join()
not string concatenation for filename.
} | ||
|
||
if (import.meta.main) { | ||
await main(); |
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.
why two if(import.meta.main)
blocks?
await main(); | ||
} | ||
|
||
if (import.meta.main) { |
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.
why two if(import.meta.main)
blocks?
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.
Also, for true cross-platform utility use the dax
module for calling shell scripts if something is not available in Deno.
Changes
Usage
To set up the Git hooks in your project, run:
deno run --allow-write=.githooks https://raw.githubusercontent.com/netspective-labs/sql-aide/vX.Y.Z/lib/universal/git-hooks.ts init
This command initializes the .githooks directory and configures the hooks to use our Deno-based scripts.