From 17c1508d60d1f0ebb2821067f38a3c42b4da9624 Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Fri, 17 Sep 2021 14:58:28 +0300 Subject: [PATCH 1/3] ref: Add comments for changelog extraction Follow up to #287 --- src/utils/git.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/utils/git.ts b/src/utils/git.ts index 6d7c85daf..3274e5f7e 100644 --- a/src/utils/git.ts +++ b/src/utils/git.ts @@ -10,6 +10,12 @@ export interface GitChange { pr: string | null; } +// This regex relies on the default GitHub behavior where it appends the PR +// number to the end of the commit title as: `fix: Commit title (#123)`. +// This makes it very cheap and quick to extract the associated PR number just +// from the commit log locally. +// If this fails at some future, we can always revert back to using the GitHub +// API that gives you the PRs associated with a commit: https://git.io/JzUVK export const PRExtractor = /(?<=\(#)\d+(?=\)$)/; export async function getDefaultBranch( @@ -37,6 +43,11 @@ export async function getChangesSince( const { all: commits } = await git.log({ from: rev, to: 'HEAD', + // The symmetric option defaults to true, giving us all the differen commits + // between `from` and `to` whereas what we are interested is only the ones + // accessible from `to` so we get a "changelog" kind of list. + // See https://github.com/steveukx/git-js#git-log and + // https://git-scm.com/docs/gitrevisions#_dotted_range_notations for more symmetric: false, '--no-merges': null, }); From d6e311d5baa1468ea891414eff2d8a5af89dbefa Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Fri, 17 Sep 2021 16:30:21 +0300 Subject: [PATCH 2/3] Use proper English thanks to Chad lol Co-authored-by: Chad Whitacre --- src/utils/git.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/git.ts b/src/utils/git.ts index 3274e5f7e..b2b2ad507 100644 --- a/src/utils/git.ts +++ b/src/utils/git.ts @@ -43,8 +43,8 @@ export async function getChangesSince( const { all: commits } = await git.log({ from: rev, to: 'HEAD', - // The symmetric option defaults to true, giving us all the differen commits - // between `from` and `to` whereas what we are interested is only the ones + // The symmetric option defaults to true, giving us all the different commits + // between `from` and `to` whereas what we are interested in is only the ones // accessible from `to` so we get a "changelog" kind of list. // See https://github.com/steveukx/git-js#git-log and // https://git-scm.com/docs/gitrevisions#_dotted_range_notations for more From 2c634762441fdc81aa3ebbf63c453df0e3ed140e Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Fri, 17 Sep 2021 17:29:49 +0300 Subject: [PATCH 3/3] Clarify symmetrical option comment Co-authored-by: Chad Whitacre --- src/utils/git.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utils/git.ts b/src/utils/git.ts index b2b2ad507..ab1609d9c 100644 --- a/src/utils/git.ts +++ b/src/utils/git.ts @@ -44,8 +44,9 @@ export async function getChangesSince( from: rev, to: 'HEAD', // The symmetric option defaults to true, giving us all the different commits - // between `from` and `to` whereas what we are interested in is only the ones - // accessible from `to` so we get a "changelog" kind of list. + // reachable from both `from` and `to` whereas what we are interested in is only the ones + // reachable from `to` and _not_ from `from` so we get a "changelog" kind of list. + // One is `A - B` and the other is more like `A XOR B`. We want `A - B`. // See https://github.com/steveukx/git-js#git-log and // https://git-scm.com/docs/gitrevisions#_dotted_range_notations for more symmetric: false,