Skip to content

Commit

Permalink
raaaahhhhhhhh
Browse files Browse the repository at this point in the history
  • Loading branch information
GitHub Actions committed Jul 23, 2023
1 parent b529b49 commit 8a93d2c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 18 deletions.
23 changes: 17 additions & 6 deletions build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const run = async () => {
else {
core.debug(`Files to format: ${files.join(', ')}`);
for (const file of files) {
const { err, stdOut } = await execute(`rstfmt "${file}"`, { silent: false });
const { err, stdOut } = await execute(`rstfmt "${file}" > "${file}"`, { silent: false });
if (err) {
core.setFailed(stdOut);
}
Expand All @@ -76,14 +76,25 @@ const run = async () => {
if (commit) {
await execute(`git config user.name "${githubUsername}"`, { silent: true });
await execute("git config user.email ''", { silent: true });
const { err: diffErr } = await execute("git diff --quiet", { silent: true });
if (!diffErr) {
const { stdOut } = await execute("git status --porcelain", {
silent: true,
});
if (stdOut.trim() === "") {
core.info("Nothing to commit!");
}
else {
await execute(`git add .`);
await execute(`git commit -m "${commitMessage}"`);
await execute("git push", { silent: true });
try {
await execute(`git commit --all -m "${commitMessage}"`);
await execute("git push", { silent: true });
}
catch (err) {
if (err instanceof Error) {
core.setFailed(err.message);
}
else {
core.setFailed("An error occurred.");
}
}
}
}
};
Expand Down
33 changes: 21 additions & 12 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const run = async () => {
} else {
core.debug(`Files to format: ${files.join(', ')}`);
for (const file of files) {
const { err, stdOut } = await execute(`rstfmt "${file}"`, { silent: false });
const { err, stdOut } = await execute(`rstfmt "${file}" > "${file}"`, { silent: false });
if (err) {
core.setFailed(stdOut);
}
Expand All @@ -59,24 +59,33 @@ const run = async () => {
await execute(`git config user.name "${githubUsername}"`, { silent: true });
await execute("git config user.email ''", { silent: true });

const { err: diffErr } = await execute("git diff --quiet", { silent: true });
const { stdOut } = await execute("git status --porcelain", {
silent: true,
});

if (!diffErr) {
if (stdOut.trim() === "") {
core.info("Nothing to commit!");
} else {
await execute(`git add .`);
await execute(`git commit -m "${commitMessage}"`);
await execute("git push", { silent: true });
try {
await execute(`git commit --all -m "${commitMessage}"`);
await execute("git push", { silent: true });
} catch (err: unknown) {
if (err instanceof Error) {
core.setFailed(err.message);
} else {
core.setFailed("An error occurred.");
}
}
}
}
};

try {
run();
run();
} catch (err: unknown) {
if (err instanceof Error) {
core.setFailed(err.message);
} else {
core.setFailed("An error occurred.");
}
if (err instanceof Error) {
core.setFailed(err.message);
} else {
core.setFailed("An error occurred.");
}
}

0 comments on commit 8a93d2c

Please sign in to comment.