Skip to content

Commit

Permalink
Merge pull request #1362 from mikepenz/develop
Browse files Browse the repository at this point in the history
dev -> main
  • Loading branch information
mikepenz authored Aug 7, 2024
2 parents f3fc77b + 4fe050c commit 346d974
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 56 deletions.
81 changes: 41 additions & 40 deletions README.md

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions __tests__/transform.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ mergedPullRequests.push(
mergedAt: moment(),
mergeCommitSha: 'sha1',
author: 'Mike',
authorName: 'Mike',
repoName: 'test-repo',
labels: [],
milestone: '',
Expand All @@ -60,6 +61,7 @@ mergedPullRequests.push(
mergedAt: moment(),
mergeCommitSha: 'sha1',
author: 'Mike',
authorName: 'Mike',
repoName: 'test-repo',
labels: [],
milestone: '',
Expand All @@ -78,6 +80,7 @@ mergedPullRequests.push(
mergedAt: moment(),
mergeCommitSha: 'sha1',
author: 'Mike',
authorName: 'Mike',
repoName: 'test-repo',
labels: [],
milestone: '',
Expand All @@ -96,6 +99,7 @@ mergedPullRequests.push(
mergedAt: moment(),
mergeCommitSha: 'sha1',
author: 'Mike',
authorName: 'Mike',
repoName: 'test-repo',
labels: [],
milestone: '',
Expand All @@ -116,6 +120,7 @@ const pullRequestWithLabelInBody: PullRequestInfo = {
mergedAt: moment(),
mergeCommitSha: 'sha1',
author: 'Mike',
authorName: 'Mike',
repoName: 'test-repo',
labels: [],
milestone: '',
Expand All @@ -135,6 +140,7 @@ const openPullRequest: PullRequestInfo = {
mergedAt: moment(),
mergeCommitSha: 'sha1',
author: 'Mike',
authorName: 'Mike',
repoName: 'test-repo',
labels: [],
milestone: '',
Expand Down Expand Up @@ -249,6 +255,7 @@ pullRequestsWithLabels.push(
mergedAt: moment(),
mergeCommitSha: 'sha1-1',
author: 'Mike',
authorName: 'Mike',
repoName: 'test-repo',
labels: ['feature'],
milestone: '',
Expand All @@ -267,6 +274,7 @@ pullRequestsWithLabels.push(
mergedAt: moment(),
mergeCommitSha: 'sha1-2',
author: 'Mike',
authorName: 'Mike',
repoName: 'test-repo',
labels: ['issue', 'fix'],
milestone: '',
Expand All @@ -285,6 +293,7 @@ pullRequestsWithLabels.push(
mergedAt: moment().add(1, 'days'),
mergeCommitSha: 'sha1-3',
author: 'Mike',
authorName: 'Mike',
repoName: 'test-repo',
labels: ['issue', 'feature', 'fix'],
milestone: '',
Expand All @@ -303,6 +312,7 @@ pullRequestsWithLabels.push(
mergedAt: moment(),
mergeCommitSha: 'sha1-4',
author: 'Mike',
authorName: 'Mike',
repoName: 'test-repo',
labels: [''],
milestone: '',
Expand All @@ -325,6 +335,7 @@ openPullRequestsWithLabels.push(
mergedAt: moment(),
mergeCommitSha: 'sha1',
author: 'Mike',
authorName: 'Mike',
repoName: 'test-repo',
labels: ['feature'],
milestone: '',
Expand All @@ -343,6 +354,7 @@ openPullRequestsWithLabels.push(
mergedAt: moment(),
mergeCommitSha: 'sha1',
author: 'Mike',
authorName: 'Mike',
repoName: 'test-repo',
labels: [],
milestone: '',
Expand Down
1 change: 1 addition & 0 deletions __tests__/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const buildPullRequeset = (number: number, title: string, labels: string[
mergedAt: moment(),
mergeCommitSha: 'sha',
author: 'Author',
authorName: 'Author',
repoName: 'test-repo',
labels,
milestone: '',
Expand Down
39 changes: 24 additions & 15 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/pr-collector/commits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ export interface CommitInfo {
summary: string
message: string
author: string
authorName: string
authorDate: moment.Moment
committer: string
committerName: string
commitDate: moment.Moment
}

Expand Down Expand Up @@ -117,6 +119,7 @@ export function convertCommitsToPrs(options: Options, diffInfo: DiffInfo): [Diff
mergedAt: commit.commitDate,
mergeCommitSha: commit.sha,
author: commit.author || '',
authorName: commit.authorName || '',
repoName: '',
labels: [],
milestone: '',
Expand Down
2 changes: 2 additions & 0 deletions src/pr-collector/pullRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface PullRequestInfo {
mergedAt: moment.Moment | undefined
mergeCommitSha: string
author: string
authorName: string
repoName: string
labels: string[]
milestone: string
Expand Down Expand Up @@ -45,6 +46,7 @@ export const EMPTY_PULL_REQUEST_INFO: PullRequestInfo = {
createdAt: moment(),
mergeCommitSha: '',
author: '',
authorName: '',
repoName: '',
labels: [],
milestone: '',
Expand Down
3 changes: 3 additions & 0 deletions src/repositories/GiteaRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export class GiteaRepository extends BaseRepository {
mergedAt: pr.merged_at ? moment(pr.merged_at) : undefined,
mergeCommitSha: pr.merge_commit_sha || '',
author: pr.user?.login || '',
authorName: pr.user?.full_name || '',
repoName: pr.base?.repo?.full_name || '',
labels: pr.labels?.map(label => label.name?.toLowerCase()) as string[],
milestone: pr.milestone?.title || '',
Expand Down Expand Up @@ -134,8 +135,10 @@ export class GiteaRepository extends BaseRepository {
summary: subject,
message: '', // This would require another git command to get the full message if needed
author: authorName,
authorName,
authorDate: moment(authorDate, 'ddd MMM DD HH:mm:ss YYYY ZZ', false),
committer: committerName,
committerName,
commitDate: moment(committerDate, 'ddd MMM DD HH:mm:ss YYYY ZZ', false),
prNumber: undefined // This is not available directly from git, would require additional logic to associate commits with PRs
}
Expand Down
3 changes: 3 additions & 0 deletions src/repositories/GithubRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ export class GithubRepository extends BaseRepository {
summary: commit.commit.message.split('\n')[0],
message: commit.commit.message,
author: commit.author?.login || commit.commit.author?.name || '',
authorName: commit.commit.author?.name || '',
authorDate: moment(commit.commit.author?.date),
committer: commit.committer?.login || '',
committerName: commit.committer?.name || '',
commitDate: moment(commit.commit.committer?.date),
prNumber: undefined
}))
Expand Down Expand Up @@ -269,6 +271,7 @@ export class GithubRepository extends BaseRepository {
mergedAt: pr.merged_at ? moment(pr.merged_at) : undefined,
mergeCommitSha: pr.merge_commit_sha || '',
author: pr.user?.login || '',
authorName: pr.user?.name || '',
repoName: pr.base.repo.full_name,
labels: this.attachSpecialLabels(status, pr.labels?.map(lbl => lbl.name?.toLocaleLowerCase('en') || '') || []),
milestone: pr.milestone?.title || '',
Expand Down
1 change: 1 addition & 0 deletions src/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ function fillPrTemplate(
placeholderMap.set('MERGED_AT', pr.mergedAt?.toISOString() || '')
placeholderMap.set('MERGE_SHA', pr.mergeCommitSha)
placeholderMap.set('AUTHOR', pr.author)
placeholderMap.set('AUTHOR_NAME', pr.authorName || '')
placeholderMap.set('LABELS', [...pr.labels]?.filter(l => !l.startsWith('--rcba-'))?.join(', ') || '')
placeholderMap.set('MILESTONE', pr.milestone || '')
placeholderMap.set('BODY', pr.body)
Expand Down

0 comments on commit 346d974

Please sign in to comment.