feat: display author of changes in workflow tab (#5780)
This commit is contained in:
@ -570,11 +570,27 @@ export default class API {
|
||||
}
|
||||
}
|
||||
|
||||
async getPullRequestAuthor(pullRequest: Octokit.PullsListResponseItem) {
|
||||
if (!pullRequest.user?.login) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const user: GitHubUser = await this.request(`/users/${pullRequest.user.login}`);
|
||||
return user.name || user.login;
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
async retrieveUnpublishedEntryData(contentKey: string) {
|
||||
const { collection, slug } = this.parseContentKey(contentKey);
|
||||
const branch = branchFromContentKey(contentKey);
|
||||
const pullRequest = await this.getBranchPullRequest(branch);
|
||||
const { files } = await this.getDifferences(this.branch, pullRequest.head.sha);
|
||||
const [{ files }, pullRequestAuthor] = await Promise.all([
|
||||
this.getDifferences(this.branch, pullRequest.head.sha),
|
||||
this.getPullRequestAuthor(pullRequest),
|
||||
]);
|
||||
const diffs = await Promise.all(files.map(file => this.diffFromFile(file)));
|
||||
const label = pullRequest.labels.find(l => isCMSLabel(l.name, this.cmsLabelPrefix)) as {
|
||||
name: string;
|
||||
@ -587,6 +603,7 @@ export default class API {
|
||||
status,
|
||||
diffs: diffs.map(d => ({ path: d.path, newFile: d.newFile, id: d.sha })),
|
||||
updatedAt,
|
||||
pullRequestAuthor,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -72,6 +72,14 @@ type GraphQLPullRequest = {
|
||||
id: string;
|
||||
isFork: boolean;
|
||||
};
|
||||
user: GraphQLPullsListResponseItemUser;
|
||||
};
|
||||
|
||||
type GraphQLPullsListResponseItemUser = {
|
||||
avatar_url: string;
|
||||
login: string;
|
||||
url: string;
|
||||
name: string;
|
||||
};
|
||||
|
||||
function transformPullRequest(pr: GraphQLPullRequest) {
|
||||
@ -272,6 +280,11 @@ export default class GraphQLAPI extends API {
|
||||
}
|
||||
}
|
||||
|
||||
async getPullRequestAuthor(pullRequest: Octokit.PullsListResponseItem) {
|
||||
const user = pullRequest.user as unknown as GraphQLPullsListResponseItemUser;
|
||||
return user?.name || user?.login;
|
||||
}
|
||||
|
||||
async getPullRequests(
|
||||
head: string | undefined,
|
||||
state: PullRequestState,
|
||||
|
@ -51,6 +51,12 @@ export const pullRequest = gql`
|
||||
title
|
||||
merged_at: mergedAt
|
||||
updated_at: updatedAt
|
||||
user: author {
|
||||
login
|
||||
... on User {
|
||||
name
|
||||
}
|
||||
}
|
||||
repository {
|
||||
...RepositoryParts
|
||||
}
|
||||
|
Reference in New Issue
Block a user