Skip to content

Commit

Permalink
Fix issue with git info capture (#536)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjohnsonpint authored Oct 30, 2024
1 parent f2e9f46 commit 58367b4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## 2024-10-30 - AssemblyScript SDK 0.13.2

- Fix issue with git info capture [#536](https://github.com/hypermodeinc/modus/pull/536)

## 2024-10-30 - Runtime Version 0.13.1

- Add env file callback support for auth key reloading [#520](https://github.com/hypermodeinc/modus/pull/520)
Expand Down
34 changes: 21 additions & 13 deletions sdk/assemblyscript/src/transform/src/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,22 +180,30 @@ function isGitRepo(): boolean {
}
}

function getGitRepo(): string {
let url = execSync("git remote get-url origin").toString().trim();
function getGitRepo(): string | undefined {
try {
let url = execSync("git remote get-url origin").toString().trim();

// Convert ssh to https
if (url.startsWith("git@")) {
url = url.replace(":", "/").replace("git@", "https://");
}
// Convert ssh to https
if (url.startsWith("git@")) {
url = url.replace(":", "/").replace("git@", "https://");
}

// Remove the .git suffix
if (url.endsWith(".git")) {
url = url.slice(0, -4);
}
// Remove the .git suffix
if (url.endsWith(".git")) {
url = url.slice(0, -4);
}

return url;
return url;
} catch {
return undefined;
}
}

function getGitCommit(): string {
return execSync("git rev-parse HEAD").toString().trim();
function getGitCommit(): string | undefined {
try {
return execSync("git rev-parse HEAD").toString().trim();
} catch {
return undefined;
}
}

0 comments on commit 58367b4

Please sign in to comment.