Last active
January 7, 2025 02:43
-
-
Save ravgeetdhillon/a5988592fd0c376d1fbfedf25262bf75 to your computer and use it in GitHub Desktop.
Script to get all commits that a GitHub user has made after a given date in all repositories owned by the given owner
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
"use strict"; | |
const PR_NUMBER = "2454"; // pr number for master to production merge | |
const execSync = require("child_process").execSync; | |
const getCommitsUnderPrQuery = `gh pr view ${PR_NUMBER} --json "commits"`; | |
const commitsUnderPrQueryResponse = JSON.parse( | |
execSync(getCommitsUnderPrQuery, (error, stdout, stderr) => stdout).toString() | |
); | |
const { commits } = commitsUnderPrQueryResponse; | |
const commitsWithPrQuery = (commitSha) => | |
`gh pr list --search "${commitSha}" --state="merged" --json="url,number,author"`; | |
const prsIncluded = commits.reduce((prev, commit) => { | |
const commitsWithPrQueryResponse = JSON.parse( | |
execSync( | |
commitsWithPrQuery(commit.oid), | |
(error, stdout, stderr) => stdout | |
).toString() | |
); | |
return [...prev, { ...commitsWithPrQueryResponse[0], commit }]; | |
}, []); | |
const result = Array.from( | |
new Set(prsIncluded.map((pr) => `${pr.url} @${pr.author.login}`)) | |
); | |
console.log(result.join("\n- ")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment