Skip to content

Commit

Permalink
fix: fix git refactor (#24)
Browse files Browse the repository at this point in the history
* fix: maybe fix CI

* mre
  • Loading branch information
sylc committed Feb 11, 2024
1 parent d40bfd5 commit 26d739e
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup latest deno version
uses: denolib/setup-deno@v2
with:
deno-version: v1.x
uses: denoland/setup-deno@v1

- name: Verify formatting
run: deno fmt --check

- name: Verify lint
run: deno lint

- name: Verify ts
run: deno check ./cli.ts
6 changes: 3 additions & 3 deletions src/branch.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { git } from "./git.ts";
import { ReleaseError } from "./error.ts";

export async function fetchBranch(repo: string): Promise<string> {
const [status, output, err] = await git(repo, "rev-parse --abbrev-ref HEAD");
if (!status.success) throw new ReleaseError("GIT_EXE", err);
export function fetchBranch(repo: string): string {
const [success, output, err] = git(repo, "rev-parse --abbrev-ref HEAD");
if (!success) throw new ReleaseError("GIT_EXE", err);
return output.trim();
}
4 changes: 2 additions & 2 deletions src/commits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ export async function fetchRawCommits(
const spec = ["s", "n", "ae", "b"]; // add at
const format = `${inner} %${spec.join(`${inner}%`)}${outer}`;

const [status, output, err] = await git(repo, [
const [success, output, err] = await git(repo, [
"rev-list",
`--pretty=format:${format}`,
"--header",
rev ?? "HEAD",
]);
if (!status.success) throw new ReleaseError("GIT_EXE", err);
if (!success) throw new ReleaseError("GIT_EXE", err);

let commits: RawCommit[] = [];
const parts = output
Expand Down
4 changes: 2 additions & 2 deletions src/repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export async function fetchRepo(path: string): Promise<Repo> {
throw new ReleaseError("NO_REPO");
}

const branch = await fetchBranch(path);
const branch = fetchBranch(path);
if (branch === "HEAD") throw new ReleaseError("UNINITIALIZED_REPO");

const config = await fetchConfig(path);
Expand Down Expand Up @@ -65,7 +65,7 @@ export async function fetchRepo(path: string): Promise<Repo> {
const tags = await fetchTags(path);
const commits = await fetchCommits(path, tags);

const status = await fetchStatus(path);
const status = fetchStatus(path);

return {
path,
Expand Down
6 changes: 3 additions & 3 deletions src/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ interface Changes {
renamed: Rename[];
}

export async function fetchStatus(repo: string): Promise<Status> {
const [status, output, err] = await git(repo, "status --porcelain");
if (!status.success) throw new ReleaseError("GIT_EXE", err);
export function fetchStatus(repo: string): Status {
const [success, output, err] = git(repo, "status --porcelain");
if (!success) throw new ReleaseError("GIT_EXE", err);

const S: Status = {
raw: [],
Expand Down
4 changes: 2 additions & 2 deletions src/tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ export async function fetchTags(repo: string, options?: FetchOptions | string) {
? `log --simplify-by-decoration ${fmt} ${rev}`
: `log --no-walk --tags ${fmt}`;

const [status, output, err] = await git(repo, cmd);
if (!status.success) throw new ReleaseError("GIT_EXE", err);
const [success, output, err] = await git(repo, cmd);
if (!success) throw new ReleaseError("GIT_EXE", err);

const lines = output.split("\n");
const tags = lines.map(parseLine).flat();
Expand Down

0 comments on commit 26d739e

Please sign in to comment.