Last active
February 2, 2021 15:05
-
-
Save BrianJenney/65f8fe748f6c760332314c9ab33b98e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const https = require('https'); | |
//////////// UPDATE THESE VALUES ///////////// | |
const releaseBranch = 'release_branch'; | |
const masterBranch = 'main'; | |
const githubUsername = 'username'; | |
const githubPassword = 'pw'; | |
////////////////////////////////////////////// | |
// let's use a set so we don't count the same story/repo more than once | |
const stories = new Set(); | |
const projects = new Set(); | |
let processedRepos = 0; | |
const repos = [ | |
'burrito-finder-app', | |
]; | |
repos.forEach((repo) => { | |
https.get( | |
{ | |
hostname: 'api.bitbucket.org', | |
path: `/2.0/repositories/company_name/${repo}/commits?include=${releaseBranch}&exclude=${masterBranch}`, //what is NOT in master that IS on our release branch? | |
headers: { | |
Authorization: `Basic ${new Buffer.from( | |
`${githubUsername}:${githubPassword}`, | |
).toString('base64')}`, | |
}, | |
}, | |
(res) => { | |
res.setEncoding('utf8'); | |
let rawData = ''; | |
res.on('data', (chunk) => { | |
rawData += chunk; | |
}); | |
res.on('end', () => { | |
try { | |
const data = JSON.parse(rawData); | |
if (data.values) { | |
const commits = data.values; | |
commits.forEach((commit) => { | |
const message = commit.rendered.message.raw; | |
const story = message.match('STORY-[0-9]*'); //or however you name your stories - this will pick up STORY-123, etc. | |
projects.add(repo); | |
if (story) { | |
stories.add(story[0]); | |
} | |
}); | |
} | |
processedRepos++; | |
if (processedRepos >= repos.length) { | |
console.log(); | |
console.log( | |
'Stories not yet in master (please confirm with team): ', | |
); | |
console.log(Array.from(stories).join(',')); | |
console.log('-----------------------'); | |
console.log(); | |
console.log( | |
'Projects to be released (please confirm with team): ', | |
); | |
console.log(Array.from(projects).join(',')); | |
console.log('-----------------------'); | |
console.log(); | |
console.log('JIRA QUERY URL (stories to bulk update): '); // you're using JIRA right? | |
console.log( | |
`https://your_company.atlassian.net/issues/?jql=id%20in%20(${Array.from( | |
stories, | |
).join('%2C%20')})`, | |
); | |
console.log('-----------------------'); | |
} | |
} catch (e) { | |
console.error(e.message); | |
} | |
}); | |
}, | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment