-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add script to remove duplicate issues on declarations repository #1115
Conversation
Example result: OpenTermsArchive/contrib-declarations#3499 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
Co-authored-by: Clément Biron <[email protected]>
@@ -2,6 +2,14 @@ | |||
|
|||
All changes that impact users of this module are documented in this file, in the [Common Changelog](https://common-changelog.org) format with some additional specifications defined in the CONTRIBUTING file. This codebase adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | |||
|
|||
## Unreleased [minor] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say this is a no-release
considering there is strictly no change in behavior exposed to reusers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered that initially, but if we ask our partners to update to the latest version to access this script, they won’t be able to do so if there’s no official release available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, true 😅
scripts/reporter/duplicate/README.md
Outdated
OTA_ENGINE_GITHUB_TOKEN=your_github_token | ||
``` | ||
|
||
2. Configure the target repository in `config/development.json`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it really have to be in
development
? Or just in the environment that will be loaded at config loading time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be in any config file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
scripts/reporter/duplicate/index.js
Outdated
continue; | ||
} | ||
|
||
await octokit.request('PATCH /repos/{owner}/{repo}/issues/{issue_number}', { /* eslint-disable-line no-await-in-loop */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we await
? Couldn't this be done fully asynchronously?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could, but I find logs much easier to read when they’re sequential. Since we need to not send our requests in parallel to avoid hitting GitHub’s rate limit, I opted for a setup that maintains clear, readable output
scripts/reporter/duplicate/index.js
Outdated
state: 'closed', | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't we use state_reason
to avoid the following comment
request? 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it is not what you think:
state_reason string or null
The reason for the state change. Ignored unless state is changed.
Can be one of: completed, not_planned, reopened, null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, sorry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could still set not_planned
then 😉
scripts/reporter/duplicate/index.js
Outdated
|
||
console.log(`\nDuplicate removal process completed; ${counter} issues closed`); | ||
} catch (error) { | ||
console.log(`Failed to remove duplicate issues: ${error.stack}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console.log(`Failed to remove duplicate issues: ${error.stack}`); | |
console.log(`Failed to remove some duplicate issues: ${error.stack}`); |
scripts/reporter/duplicate/index.js
Outdated
} | ||
|
||
console.log(`\nDuplicate removal process completed; ${counter} issues closed`); | ||
} catch (error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do a try
/ catch
and exit
instead of simply not catching any error, since we call the function from the main event loop anyway? 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of habit. But it can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would still be happy to see my comments handled, but nothing blocking 🙂
Output example: