-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(author): return user who triggered the workflow
by retrieving the commit's author
- Loading branch information
Showing
6 changed files
with
140 additions
and
9 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { OctokitFactory } from './OctokitFactory'; | ||
import { RepoName } from '../../domain/IRepoRepository'; | ||
|
||
export interface CommitAuthor { | ||
readonly login: string; | ||
readonly name?: string; | ||
} | ||
export interface ICommitAuthorRepository { | ||
getAuthorForCommit( | ||
token: string, | ||
repoName: RepoName, | ||
commitId: string | ||
): Promise<CommitAuthor | null>; | ||
} | ||
|
||
export class CommitAuthorRepository implements ICommitAuthorRepository { | ||
public constructor(private readonly octokitFactory: OctokitFactory) {} | ||
|
||
public async getAuthorForCommit( | ||
token: string, | ||
repoName: RepoName, | ||
commitId: string | ||
): Promise<CommitAuthor | null> { | ||
const octokit = this.octokitFactory(token); | ||
|
||
const response = await octokit.repos.getCommit({ | ||
owner: repoName.owner, | ||
repo: repoName.name, | ||
ref: commitId, | ||
}); | ||
|
||
if (!response.data.author) { | ||
return null; | ||
} | ||
|
||
const result = { | ||
login: response.data.author.login, | ||
name: response.data.commit.author?.name, | ||
}; | ||
return result; | ||
} | ||
} |
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
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