Skip to content

Commit a5f8897

Browse files
fix(script): --ignore flag was not working properly for all scenarios (#5)
* fix(script): --ignore flag was not working properly for all scenarios * empty commit to preset the squash & merge commit subject from the pull request title Created by https://github.com/gr2m/squash-commit-app Co-authored-by: squash-commit-app[bot] <83693605+squash-commit-app[bot]@users.noreply.github.com>
1 parent 2f558fe commit a5f8897

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

script.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export async function script(octokit, repository, { unwatch, ignore }) {
1010
throw new Error("Combination of flags not allowed. Use either --unwatch or --ignore, not both")
1111
}
1212

13+
const subscribe = !ignore && !unwatch
1314
const method = unwatch ? "DELETE" : "PUT";
1415
const id = repository.id;
1516
const owner = repository.owner.login;
@@ -24,16 +25,17 @@ export async function script(octokit, repository, { unwatch, ignore }) {
2425
({ data: { subscribed, ignored } }) => ({ subscribed, ignored }),
2526
() => ({ subscribed: false, ignored: false })
2627
);
28+
const unsubscribed = !subscribed && !ignored
2729

2830
octokit.log.debug(
2931
{
3032
change: 0,
3133
},
3234
"subscribed: %s, ignored: %s, unwatch: %s, ignore: %s",
33-
subscribed, ignored, unwatch, ignore
35+
subscribed, ignored, !!unwatch, !!ignore
3436
);
3537

36-
if ((unwatch && !subscribed) || (!unwatch && subscribed) || (ignored && ignore)) {
38+
if ((subscribed && subscribe) || (ignored && ignore) || (unsubscribed && unwatch)) {
3739
octokit.log.debug(
3840
{
3941
change: 0,

0 commit comments

Comments
 (0)