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

Fix issue with git info capture #536

Merged
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
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;
}
}