Skip to content

Commit

Permalink
Check commit needed
Browse files Browse the repository at this point in the history
  • Loading branch information
Larsluph committed Nov 12, 2023
1 parent a44fef8 commit c048807
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
12 changes: 12 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25568,6 +25568,7 @@ const exec_1 = __nccwpck_require__(1514);
const io_1 = __nccwpck_require__(7436);
const io_util_1 = __nccwpck_require__(1962);
const fs = __importStar(__nccwpck_require__(7147));
const stream_1 = __nccwpck_require__(2781);
const base_url = 'https://app.tolgee.io/v2';
const languages_url = `${base_url}/projects/languages`;
const export_url = `${base_url}/projects/export`;
Expand Down Expand Up @@ -25623,6 +25624,17 @@ async function commitChanges(committer_name, committer_email, commit_message) {
return;
}
const gitPath = await (0, io_1.which)('git', true);
let hasChanged = false;
const outStream = new stream_1.Writable({
write(chunk, encoding, callback) {
hasChanged = true;
}
});
await (0, exec_1.exec)(gitPath, ['status', '-s'], { outStream });
if (!hasChanged) {
core.info('Nothing to commit.');
return;
}
await (0, exec_1.exec)(gitPath, ['add', '.']);
await (0, exec_1.exec)(gitPath, ['config', '--global', 'user.name', committer_name]);
await (0, exec_1.exec)(gitPath, ['config', '--global', 'user.email', committer_email]);
Expand Down
15 changes: 15 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { HttpClient } from '@actions/http-client'
import { mkdirP, which } from '@actions/io'
import { rm } from '@actions/io/lib/io-util'
import * as fs from 'fs'
import { Writable } from 'stream'
import { LanguageResponse } from './types'

const base_url = 'https://app.tolgee.io/v2'
Expand Down Expand Up @@ -72,6 +73,20 @@ export async function commitChanges(committer_name: string, committer_email: str
}

const gitPath = await which('git', true)

let hasChanged = false
const outStream = new Writable({
write(chunk, encoding, callback) {
hasChanged = true
}
})
await exec(gitPath, ['status', '-s'], { outStream })

if (!hasChanged) {
core.info('Nothing to commit.')
return
}

await exec(gitPath, ['add', '.'])
await exec(gitPath, ['config', '--global', 'user.name', committer_name])
await exec(gitPath, ['config', '--global', 'user.email', committer_email])
Expand Down

0 comments on commit c048807

Please sign in to comment.