Skip to content
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

D reminder label support #3121

Merged
merged 3 commits into from
Dec 25, 2023
Merged
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
38 changes: 26 additions & 12 deletions lib/stableBrandNewReminder.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,26 @@
const {
addLabel,
createLabel,
deleteLabel,
getLabels,
getAllComments,
getGithub,
} = require('./common');

async function doIt() {
let labels = await getLabels('');
labels = labels.forEach( (l)=> {
const result = /^(\d\d)\.(\d\d)\.(\d\d\d\d)$/g.exec(l.name);
if (result) {
let targetTs=new Date(result[3], result[2]-1, result[1], 0, 0, 0).getTime();
const nowTs = new Date().getTime();
if ( nowTs > targetTs + 2* 24*60*60*1000) {
console.log(`Label ${l.name} is outdated and will be removed`);
deleteLabel('', l.name);
}
};
});
Comment on lines +13 to +23

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

The value assigned to labels here is unused.

const issues = await getGithub(`https://api.github.com/repos/iobroker/ioBroker.repositories/issues`);
for (const issue of issues ) {
if (issue.labels.find(label => label.name === 'STABLE - brand new')) {
Expand All @@ -27,14 +41,14 @@
const nowTs = new Date().getTime();
if ( nowTs < targetTs ) {
console.log(` will merged after ${dateStr}`);
const label = `* ${dateStr} *`;
const labels = await getLabels('');
//if ( ! labels.filter( (f) => { console.log( f.name ); return f.name===`${label}`})) {
if ( ! labels.includes(`${label}`)) {
const label = `${dateStr}`;
let labels = await getLabels('');
labels = labels.filter( (f) => { return f.name===`${label}`} );
if (!labels.length) {
console.log(` will create label $label}`);
await createLabel(`${label}`, `remind after ${dateStr}`, `#ffffff`);
await createLabel(`${label}`, `remind after ${dateStr}`, `ffffff`);
}
await addLabel(`${issue.number}`, `${label}`);
await addLabel(issue.number, [`${label}`]);
} else {
console.log(` should be merged now (deadline ${dateStr})`);
await addLabel(issue.number, ['⚠️check']);
Expand All @@ -52,14 +66,14 @@
const nowTs = Date.now();
if ( nowTs < targetTs ) {
console.log(` will remind at ${dateStr}`);
const label = `* ${dateStr} *`;
const labels = await getLabels('');
//if ( ! labels.filter( (f) => { console.log( f.name ); return f.name===`${label}`})) {
if ( ! labels.includes(`${label}`)) {
const label = `${dateStr}`;
let labels = await getLabels('');
labels = labels.filter( (f) => { return f.name===`${label}`} );
if (!labels.length) {
console.log(` will create label ${label}`);
await createLabel(`${label}`, `remind after ${dateStr}`, `#ffffff`);
await createLabel(`${label}`, `remind after ${dateStr}`, `ffffff`);
}
await addLabel(`${issue.number}`, `${label}`);
await addLabel(issue.number, [`${label}`]);
} else {
console.log(` should be checked now (deadline ${dateStr})`);
await addLabel(issue.number, ['⚠️check']);
Expand Down