Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Check and warn if a Pull Request will conflict with another Pull Request when th

```yaml
name: conflibot
on: pull_request_target
on: pull_request

jobs:
conflibot:
Expand Down
12 changes: 9 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10951,8 +10951,9 @@ class Conflibot {
}
run() {
return __awaiter(this, void 0, void 0, function* () {
const remotes = ["origin"];
try {
this.setStatus();
yield this.setStatus();
const pull = yield this.waitForTestMergeCommit(5, {
owner: github.context.issue.owner,
repo: github.context.issue.repo,
Expand All @@ -10978,7 +10979,12 @@ class Conflibot {
continue;
}
core.info(`Checking #${target.number} (${target.head.ref})`);
yield this.system(`git format-patch origin/${pull.data.base.ref}..origin/${target.head.ref} --stdout | git apply --check`).catch((reason) => {
if (!remotes.includes(target.head.repo.owner.login)) {
remotes.push(target.head.repo.owner.login);
yield this.system(`git remote add ${target.head.repo.owner.login} https://github.com/${target.head.repo.full_name}`);
yield this.system(`git fetch ${target.head.repo.owner.login}`);
}
yield this.system(`git format-patch origin/${pull.data.base.ref}.. ${target.head.repo.owner.login}/${target.head.ref} --stdout | git apply --check`).catch((reason) => {
// Patch application error expected. Throw an error if not.
if (!reason.toString().includes("patch does not apply")) {
throw reason[2];
Expand Down Expand Up @@ -11021,7 +11027,7 @@ class Conflibot {
.join("\n");
const sum = conflicts.map((c) => c[1].length).reduce((p, c) => p + c);
const summary = `Found ${sum} potential conflict(s) in ${conflicts.length} other PR(s)!`;
this.setStatus("neutral", { title: summary, summary, text });
yield this.setStatus("neutral", { title: summary, summary, text });
}
catch (error) {
this.exit("failure", JSON.stringify(error), "Error!");
Expand Down
15 changes: 11 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ class Conflibot {
}

async run(): Promise<void> {
const remotes = ["origin"];
try {
this.setStatus();
await this.setStatus();

const pull = await this.waitForTestMergeCommit(5, {
owner: github.context.issue.owner,
Expand Down Expand Up @@ -122,9 +123,15 @@ class Conflibot {
continue;
}
core.info(`Checking #${target.number} (${target.head.ref})`);

if (!remotes.includes(target.head.repo.owner.login)) {
remotes.push(target.head.repo.owner.login);
await this.system(
`git remote add ${target.head.repo.owner.login} https://github.com/${target.head.repo.full_name}`,
);
await this.system(`git fetch ${target.head.repo.owner.login}`);
}
await this.system(
`git format-patch origin/${pull.data.base.ref}..origin/${target.head.ref} --stdout | git apply --check`,
`git format-patch origin/${pull.data.base.ref}.. ${target.head.repo.owner.login}/${target.head.ref} --stdout | git apply --check`,
).catch((reason: [string, string, string]) => {
// Patch application error expected. Throw an error if not.
if (!reason.toString().includes("patch does not apply")) {
Expand Down Expand Up @@ -179,7 +186,7 @@ class Conflibot {

const sum = conflicts.map((c) => c[1].length).reduce((p, c) => p + c);
const summary = `Found ${sum} potential conflict(s) in ${conflicts.length} other PR(s)!`;
this.setStatus("neutral", { title: summary, summary, text });
await this.setStatus("neutral", { title: summary, summary, text });
} catch (error) {
this.exit("failure", JSON.stringify(error), "Error!");
}
Expand Down