MCPcopy Create free account
hub / github.com/tensorflow/tfjs / getReleaseNotesDraft

Function getReleaseNotesDraft

scripts/release_notes/util.ts:132–242  ·  view source on GitHub ↗
(
    octokit: OctokitGetCommit, repoCommits: RepoCommits[])

Source from the content-addressed store, hash-verified

130 * @returns The release notes markdown draft as a string.
131 */
132export async function getReleaseNotesDraft(
133 octokit: OctokitGetCommit, repoCommits: RepoCommits[]): Promise<string> {
134 const repoNotes: string[] = [];
135 for (let i = 0; i < repoCommits.length; i++) {
136 const repoCommit = repoCommits[i];
137
138 const getUsernameForCommit = async (sha: string) => {
139 let result;
140 try {
141 result = await octokit.repos.getCommit(
142 {owner: 'tensorflow', repo: 'tfjs', sha});
143 return result.data.author.login;
144 } catch (e) {
145 console.log(`Error fetching username for commit ${sha}`);
146 console.log(`Using ${result.data.commit.author.name}`);
147 return result.data.commit.author.name;
148 }
149 };
150
151 const tagEntries: {[tag: string]: string[]} = {};
152 SECTION_TAGS.forEach(({tag}) => tagEntries[tag] = []);
153
154 for (let j = 0; j < repoCommit.commits.length; j++) {
155 const commit = repoCommit.commits[j];
156
157 const tagsFound: Array<{tag: string, tagMessage: string}> = [];
158 const bodyLines = commit.body.split('\n').map(line => line.trim());
159 // Get tags for the body by finding lines that start with tags. Do
160 // this without a regex for readability.
161 SECTION_TAGS.forEach(({tag}) => {
162 if (tag === 'INTERNAL') {
163 return;
164 }
165
166 bodyLines.forEach(line => {
167 // Split by word boundaries, and make sure the first word is the
168 // tag.
169 const split = line.split(/\b/);
170 if (split[0] === tag) {
171 const tagMessage = line.substring(tag.length).trim();
172 tagsFound.push({tag, tagMessage});
173 }
174 });
175 });
176 // If no explicit tags, put this under misc.
177 if (tagsFound.length === 0) {
178 tagsFound.push({tag: 'MISC', tagMessage: ''});
179 }
180
181 const username = await getUsernameForCommit(commit.sha);
182 const isExternalContributor =
183 !commit.authorEmail.endsWith('@google.com') &&
184 !isGooglerUsername(username);
185
186 const pullRequestRegexp = /\(#([0-9]+)\)/;
187 const pullRequestMatch = commit.subject.match(pullRequestRegexp);
188
189 let subject = commit.subject;

Callers

nothing calls this directly

Calls 5

getUsernameForCommitFunction · 0.85
isGooglerUsernameFunction · 0.85
joinMethod · 0.80
splitMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…