Skip to content
Merged
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
19 changes: 13 additions & 6 deletions src/git-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,12 @@ export class GitData {

try {
await Promise.all(promises);
} catch (e) {
} catch (e: any) {
if (e instanceof AssertionError) {
return writeStreams.stderr(chalk`{yellow ${e.message}}\n`);
}
writeStreams.stderr(chalk`{yellow Using fallback git commit data}\n`);
writeStreams.stderr(chalk`{yellow ${e.message}\n}`);
}
}

Expand All @@ -73,9 +74,11 @@ export class GitData {
this.branches.default = gitRemoteDefaultBranch.replace("origin/", "");
} catch (e: any) {
if (e.stderr === "fatal: ref refs/remotes/origin/HEAD is not a symbolic ref") {
writeStreams.stderr(chalk`{yellow Unable to retrieve default remote branch, falling back to \`${this.branches.default}\`. The default remote branch can be set via \`git remote set-head origin <default_branch>\`}`);
writeStreams.stderr(chalk`{yellow Unable to retrieve default remote branch, falling back to \`${this.branches.default}\`. The default remote branch can be set via \`git remote set-head origin <default_branch>\`\n}`);
writeStreams.stderr(chalk`{yellow ${e.message}\n}`);
} else {
writeStreams.stderr(chalk`{yellow Unable to retrieve default remote branch, falling back to \`${this.branches.default}\`.\n}`);
writeStreams.stderr(chalk`{yellow ${e.message}\n}`);
}
}
}
Expand Down Expand Up @@ -138,12 +141,13 @@ export class GitData {
this.remote.schema = "git";
this.remote.port = port;
}
} catch (e) {
} catch (e: any) {
if (e instanceof AssertionError) {
writeStreams.stderr(chalk`{yellow ${e.message}}\n`);
return;
}
writeStreams.stderr(chalk`{yellow Using fallback git remote data}\n`);
writeStreams.stderr(chalk`{yellow ${e.message}\n}`);
}
}

Expand All @@ -152,24 +156,27 @@ export class GitData {

const gitUsernamePromise = Utils.spawn(["git", "config", "user.name"], cwd).then(({stdout}) => {
this.user.GITLAB_USER_NAME = stdout.trimEnd();
}).catch(() => {
}).catch((e) => {
writeStreams.stderr(chalk`{yellow Using fallback git user.name}\n`);
writeStreams.stderr(chalk`{yellow ${e.message}\n}`);
});
promises.push(gitUsernamePromise);

const gitEmailPromise = Utils.spawn(["git", "config", "user.email"], cwd).then(({stdout}) => {
const email = stdout.trimEnd();
this.user.GITLAB_USER_EMAIL = email;
this.user.GITLAB_USER_LOGIN = email.replace(/@.*/, "");
}).catch(() => {
}).catch((e) => {
writeStreams.stderr(chalk`{yellow Using fallback git user.email}\n`);
writeStreams.stderr(chalk`{yellow ${e.message}\n}`);
});
promises.push(gitEmailPromise);

const osUidPromise = Utils.spawn(["id", "-u"], cwd).then(({stdout}) => {
this.user.GITLAB_USER_ID = stdout.trimEnd();
}).catch(() => {
}).catch((e) => {
writeStreams.stderr(chalk`{yellow Using fallback linux user id}\n`);
writeStreams.stderr(chalk`{yellow ${e.message}\n}`);
});
promises.push(osUidPromise);

Expand Down