mirror of
https://code.forgejo.org/actions/checkout.git
synced 2024-11-24 04:29:16 +01:00
adding listener
This commit is contained in:
parent
ad19603e6b
commit
5788ebd085
2 changed files with 37 additions and 24 deletions
29
dist/index.js
vendored
29
dist/index.js
vendored
|
@ -7399,7 +7399,12 @@ class GitCommandManager {
|
||||||
else {
|
else {
|
||||||
args.push('--branches');
|
args.push('--branches');
|
||||||
}
|
}
|
||||||
const output = yield this.execGit(args);
|
const listeners = {
|
||||||
|
stderr: (data) => {
|
||||||
|
core.debug(data.toString());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const output = yield this.execGit(args, false, false, listeners);
|
||||||
for (let branch of output.stdout.trim().split('\n')) {
|
for (let branch of output.stdout.trim().split('\n')) {
|
||||||
branch = branch.trim();
|
branch = branch.trim();
|
||||||
if (branch) {
|
if (branch) {
|
||||||
|
@ -7661,7 +7666,7 @@ class GitCommandManager {
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
execGit(args, allowAllExitCodes = false, silent = false) {
|
execGit(args, allowAllExitCodes = false, silent = false, customListeners = {}) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
fshelper.directoryExistsSync(this.workingDirectory, true);
|
fshelper.directoryExistsSync(this.workingDirectory, true);
|
||||||
const result = new GitOutput();
|
const result = new GitOutput();
|
||||||
|
@ -7672,20 +7677,22 @@ class GitCommandManager {
|
||||||
for (const key of Object.keys(this.gitEnv)) {
|
for (const key of Object.keys(this.gitEnv)) {
|
||||||
env[key] = this.gitEnv[key];
|
env[key] = this.gitEnv[key];
|
||||||
}
|
}
|
||||||
const stdout = ['ardvark'];
|
const defaultListener = {
|
||||||
|
stdout: (data) => {
|
||||||
|
stdout.push(data.toString());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// const listeners = Object.keys(customListeners) < 0 ? customListeners : {stdout: (data: Buffer) => {
|
||||||
|
// stdout.push(data.toString())
|
||||||
|
// }}
|
||||||
|
const listenersD = Object.assign(Object.assign({}, customListeners), defaultListener);
|
||||||
|
const stdout = [];
|
||||||
const options = {
|
const options = {
|
||||||
cwd: this.workingDirectory,
|
cwd: this.workingDirectory,
|
||||||
env,
|
env,
|
||||||
silent,
|
silent,
|
||||||
ignoreReturnCode: allowAllExitCodes,
|
ignoreReturnCode: allowAllExitCodes,
|
||||||
listeners: {
|
listeners: listenersD
|
||||||
stdout: (data) => {
|
|
||||||
stdout.push(data.toString());
|
|
||||||
},
|
|
||||||
stderr: (data) => {
|
|
||||||
stdout.push(data.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
result.exitCode = yield exec.exec(`"${this.gitPath}"`, args, options);
|
result.exitCode = yield exec.exec(`"${this.gitPath}"`, args, options);
|
||||||
result.stdout = stdout.join('');
|
result.stdout = stdout.join('');
|
||||||
|
|
|
@ -104,7 +104,12 @@ class GitCommandManager {
|
||||||
args.push('--branches')
|
args.push('--branches')
|
||||||
}
|
}
|
||||||
|
|
||||||
const output = await this.execGit(args)
|
const listeners = {
|
||||||
|
stderr: (data: Buffer) => {
|
||||||
|
core.debug(data.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const output = await this.execGit(args, false, false, listeners)
|
||||||
|
|
||||||
for (let branch of output.stdout.trim().split('\n')) {
|
for (let branch of output.stdout.trim().split('\n')) {
|
||||||
branch = branch.trim()
|
branch = branch.trim()
|
||||||
|
@ -395,7 +400,8 @@ class GitCommandManager {
|
||||||
private async execGit(
|
private async execGit(
|
||||||
args: string[],
|
args: string[],
|
||||||
allowAllExitCodes = false,
|
allowAllExitCodes = false,
|
||||||
silent = false
|
silent = false,
|
||||||
|
customListeners = {}
|
||||||
): Promise<GitOutput> {
|
): Promise<GitOutput> {
|
||||||
fshelper.directoryExistsSync(this.workingDirectory, true)
|
fshelper.directoryExistsSync(this.workingDirectory, true)
|
||||||
|
|
||||||
|
@ -408,22 +414,22 @@ class GitCommandManager {
|
||||||
for (const key of Object.keys(this.gitEnv)) {
|
for (const key of Object.keys(this.gitEnv)) {
|
||||||
env[key] = this.gitEnv[key]
|
env[key] = this.gitEnv[key]
|
||||||
}
|
}
|
||||||
|
const defaultListener = {
|
||||||
const stdout: string[] = ['ardvark']
|
stdout: (data: Buffer) => {
|
||||||
|
stdout.push(data.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// const listeners = Object.keys(customListeners) < 0 ? customListeners : {stdout: (data: Buffer) => {
|
||||||
|
// stdout.push(data.toString())
|
||||||
|
// }}
|
||||||
|
const listenersD = {...customListeners, ...defaultListener}
|
||||||
|
const stdout: string[] = []
|
||||||
const options = {
|
const options = {
|
||||||
cwd: this.workingDirectory,
|
cwd: this.workingDirectory,
|
||||||
env,
|
env,
|
||||||
silent,
|
silent,
|
||||||
ignoreReturnCode: allowAllExitCodes,
|
ignoreReturnCode: allowAllExitCodes,
|
||||||
listeners: {
|
listeners: listenersD
|
||||||
stdout: (data: Buffer) => {
|
|
||||||
stdout.push(data.toString())
|
|
||||||
},
|
|
||||||
stderr: (data: Buffer) => {
|
|
||||||
stdout.push(data.toString())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result.exitCode = await exec.exec(`"${this.gitPath}"`, args, options)
|
result.exitCode = await exec.exec(`"${this.gitPath}"`, args, options)
|
||||||
|
|
Loading…
Reference in a new issue