Skip to content

Commit

Permalink
🐞 fix: remove dotnet format report properly (#43)
Browse files Browse the repository at this point in the history
* 🐞 fix: remove dotnet format report properly

* chore: build, dist updated
  • Loading branch information
maxisam authored Oct 5, 2023
1 parent 1cbb9f4 commit 0074ac2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
19 changes: 10 additions & 9 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

20 changes: 11 additions & 9 deletions src/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,28 @@ export async function format(inputs: IInputs, githubClient: InstanceType<typeof
const reportFiles = dotnet.getReportFiles();
await git.UploadReportToArtifacts(reportFiles, REPORT_ARTIFACT_NAME);
const isDryRun = checkIsDryRun(configOptions);
const isChanged = await git.checkIsFileChanged();
if (context.eventName === 'pull_request') {
await postReportAsComment(reportFiles, githubClient);
}
const isReportRemoved = await Common.RemoveReportFiles();
const isChanged = isReportRemoved && (await git.checkIsFileChanged());
setOutput(isDryRun, isChanged);
if (finalFormatResult && context.eventName === 'pull_request') {
const isReportRemoved = await postReportasComment(reportFiles, githubClient);
if (!isDryRun && isChanged && isReportRemoved && !inputs.skipCommit) {
await commitChanges(cwd, inputs);
}
if (!isDryRun && isChanged && isReportRemoved && !inputs.skipCommit && context.eventName === 'pull_request') {
await commitChanges(cwd, inputs);
}

finalFormatResult
? core.notice('✅ DOTNET FORMAT SUCCESS', dotnet.ANNOTATION_OPTIONS)
: core.error('DOTNET FORMAT FAILED', dotnet.ANNOTATION_OPTIONS);
return finalFormatResult;
}

async function postReportasComment(reportFiles: string[], githubClient: InstanceType<typeof Octokit>): Promise<boolean> {
async function postReportAsComment(reportFiles: string[], githubClient: InstanceType<typeof Octokit>): Promise<boolean> {
if (reportFiles.length) {
const message = dotnet.generateReport(reportFiles);
await git.comment(githubClient, message);
return await git.comment(githubClient, message);
}
return await Common.RemoveReportFiles();
return true;
}

async function commitChanges(cwd: string, inputs: IInputs): Promise<boolean> {
Expand Down

0 comments on commit 0074ac2

Please sign in to comment.