Skip to content

Commit

Permalink
fix: Include args when generating Git hooks. (#1081)
Browse files Browse the repository at this point in the history
* Pass args.

* Fix hook args.

* Fix format.
  • Loading branch information
milesj authored Sep 28, 2023
1 parent 0c38cc5 commit 824c41a
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion crates/core/moon/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub async fn load_workspace() -> miette::Result<Workspace> {
if !is_test_env() {
if workspace.vcs.is_enabled() {
if let Ok(slug) = workspace.vcs.get_repository_slug().await {
env::set_var("MOON_REPO_SLUG", slug);
env::set_var("MOONBASE_REPO_SLUG", slug);
}
}

Expand Down
4 changes: 1 addition & 3 deletions nextgen/api/src/launchpad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ fn create_anonymous_rid(workspace_root: &Path) -> String {
format!(
"{:x}",
md5::compute(
env::var("MOONBASE_REPO_SLUG")
.or_else(|_| env::var("MOON_REPO_SLUG"))
.unwrap_or_else(|_| fs::file_name(workspace_root)),
env::var("MOONBASE_REPO_SLUG").unwrap_or_else(|_| fs::file_name(workspace_root)),
)
)
}
Expand Down
8 changes: 6 additions & 2 deletions nextgen/vcs-hooks/src/hooks_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl<'app> HooksGenerator<'app> {
self.create_file(
&external_path,
format!(
"#!/bin/sh\n{} -NoProfile -ExecutionPolicy Bypass -File '{}'",
"#!/bin/sh\n{} -NoProfile -ExecutionPolicy Bypass -File \"{} $1 $2 $3\"",
powershell_exe, external_command
),
)?;
Expand All @@ -151,7 +151,11 @@ impl<'app> HooksGenerator<'app> {
#[cfg(not(windows))]
{
// pre-commit
self.create_hook_file(&external_path, &[external_command], false)?;
self.create_hook_file(
&external_path,
&[format!("{} $1 $2 $3", external_command)],
false,
)?;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ expression: "fs::read_to_string(post_push).unwrap()"
#!/usr/bin/env bash
set -eo pipefail

./.moon/hooks/post-push.sh
./.moon/hooks/post-push.sh $1 $2 $3
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ expression: "fs::read_to_string(pre_commit).unwrap()"
#!/usr/bin/env bash
set -eo pipefail

./.moon/hooks/pre-commit.sh
./.moon/hooks/pre-commit.sh $1 $2 $3
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ source: nextgen/vcs-hooks/tests/hooks_generator_test.rs
expression: "out2.replace(\"powershell.exe\", \"pwsh.exe\")"
---
#!/bin/sh
pwsh.exe -NoProfile -ExecutionPolicy Bypass -File '.\.moon\hooks\post-push.ps1'
pwsh.exe -NoProfile -ExecutionPolicy Bypass -File ".\.moon\hooks\post-push.ps1 $1 $2 $3"
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ source: nextgen/vcs-hooks/tests/hooks_generator_test.rs
expression: "out1.replace(\"powershell.exe\", \"pwsh.exe\")"
---
#!/bin/sh
pwsh.exe -NoProfile -ExecutionPolicy Bypass -File '.\.moon\hooks\pre-commit.ps1'
pwsh.exe -NoProfile -ExecutionPolicy Bypass -File ".\.moon\hooks\pre-commit.ps1 $1 $2 $3"
2 changes: 2 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#### 🐞 Fixes

- Fixed an issue where non-YAML files in `.moon/tasks` would be parsed as YAML configs.
- Fixed an issue where arguments were not passed to generated Git hooks.
- Fixed an issue where moonbase would fail to sign in in CI.

## 1.14.1

Expand Down

0 comments on commit 824c41a

Please sign in to comment.