Skip to content

Commit

Permalink
Fully fix issue with git info capture (#537)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjohnsonpint authored Oct 30, 2024
1 parent 58367b4 commit 6f20dbd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 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.3

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

## 2024-10-30 - AssemblyScript SDK 0.13.2

- Fix issue with git info capture [#536](https://github.com/hypermodeinc/modus/pull/536)
Expand Down
23 changes: 19 additions & 4 deletions sdk/assemblyscript/src/transform/src/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,15 @@ export class Metadata {
m.sdk = getSdkInfo();

if (isGitRepo()) {
m.gitRepo = getGitRepo();
m.gitCommit = getGitCommit();
const gitRepo = getGitRepo();
if (gitRepo) {
m.gitRepo = getGitRepo();
}

const gitCommit = getGitCommit();
if (gitCommit) {
m.gitCommit = getGitCommit();
}
}

return m;
Expand Down Expand Up @@ -182,7 +189,11 @@ function isGitRepo(): boolean {

function getGitRepo(): string | undefined {
try {
let url = execSync("git remote get-url origin").toString().trim();
let url = execSync("git remote get-url origin", {
stdio: ["ignore", "pipe", "ignore"],
})
.toString()
.trim();

// Convert ssh to https
if (url.startsWith("git@")) {
Expand All @@ -202,7 +213,11 @@ function getGitRepo(): string | undefined {

function getGitCommit(): string | undefined {
try {
return execSync("git rev-parse HEAD").toString().trim();
return execSync("git rev-parse HEAD", {
stdio: ["ignore", "pipe", "ignore"],
})
.toString()
.trim();
} catch {
return undefined;
}
Expand Down

0 comments on commit 6f20dbd

Please sign in to comment.