Display information about cherry-picks

- Make author sorting case insensitive
This commit is contained in:
Yuri Sizov
2023-03-23 18:49:42 +01:00
parent f4c269541c
commit 080c92fbab
3 changed files with 87 additions and 35 deletions

View File

@@ -117,13 +117,18 @@ export default class ChangesList extends LitElement {
if (commit.is_cherrypick && typeof this.commits[commit.cherrypick_hash] !== "undefined") {
originalCommit = this.commits[commit.cherrypick_hash];
}
this._appendCommit(commit, originalCommit);
if (originalCommit.pull !== "" && typeof this.pulls[originalCommit.pull] !== "undefined") {
const pull = this.pulls[originalCommit.pull];
this._appendPull(pull);
let pull = null;
let originalPull = null;
if (commit.pull !== "" && typeof this.pulls[commit.pull] !== "undefined") {
pull = this.pulls[commit.pull];
originalPull = pull;
}
if (originalCommit.pull !== "" && typeof this.pulls[originalCommit.pull] !== "undefined") {
originalPull = this.pulls[originalCommit.pull];
}
this._appendPull(pull, originalPull);
});
this._filtered_authors.sort((a, b) => {
@@ -131,8 +136,8 @@ export default class ChangesList extends LitElement {
if (a.commits.length > b.commits.length) return -1;
if (a.commits.length < b.commits.length) return 1;
// Then sort by name (ASC).
if (a.author.user > b.author.user) return 1;
if (a.author.user < b.author.user) return -1;
if (a.author.user.toLowerCase() > b.author.user.toLowerCase()) return 1;
if (a.author.user.toLowerCase() < b.author.user.toLowerCase()) return -1;
return 0;
});
@@ -140,13 +145,16 @@ export default class ChangesList extends LitElement {
_appendCommit(commit, originalCommit) {
const filteredCommit = {
"commit": commit,
"original_commit": null,
"commit": null,
"cherrypick_commit": null,
"authors": [],
};
if (commit !== originalCommit) {
filteredCommit.original_commit = originalCommit;
filteredCommit.commit = originalCommit;
filteredCommit.cherrypick_commit = commit;
} else {
filteredCommit.commit = commit;
}
const authorIds = this._findCommitAuthors([ commit.hash, originalCommit.hash ]);
@@ -156,22 +164,34 @@ export default class ChangesList extends LitElement {
this._appendAuthors(filteredCommit.authors, commit);
}
_appendPull(pull) {
_appendPull(pull, originalPull) {
if (!pull || !originalPull) {
return;
}
const existing = this._filtered_pulls.find((item) => {
return item.pull === pull;
return item.pull === originalPull;
});
if (typeof existing !== "undefined") {
return;
}
const filteredPull = {
"pull": pull,
"pull": null,
"cherrypick_pull": null,
"authors": [],
};
let authorIds = this._findCommitAuthors(pull.commits);
if (authorIds.indexOf(pull.authored_by) < 0) {
authorIds.push(pull.authored_by);
if (pull !== originalPull) {
filteredPull.pull = originalPull;
filteredPull.cherrypick_pull = pull;
} else {
filteredPull.pull = pull;
}
let authorIds = this._findCommitAuthors(originalPull.commits);
if (authorIds.indexOf(originalPull.authored_by) < 0) {
authorIds.push(originalPull.authored_by);
}
filteredPull.authors = this._getAuthors(authorIds);
@@ -285,10 +305,12 @@ export default class ChangesList extends LitElement {
${this._viewMode === "pulls" ? this._filtered_pulls.map((item) => {
const pull = item.pull;
const cherrypick_pull = item.cherrypick_pull;
return html`
<gr-pull-item
.id="${pull.public_id}"
.cherrypick_id="${(cherrypick_pull ? cherrypick_pull.public_id : "")}"
.title="${pull.title}"
.authors="${item.authors}"
.url="${pull.url}"
@@ -302,10 +324,12 @@ export default class ChangesList extends LitElement {
${this._viewMode === "commits" ? this._filtered_commits.map((item) => {
const commit = item.commit;
const cherrypick_commit = item.cherrypick_commit;
return html`
<gr-commit-item
.hash="${commit.hash}"
.cherrypick_hash="${(cherrypick_commit ? cherrypick_commit.hash : "")}"
.title="${commit.summary}"
.authors="${item.authors}"
.repository="${this.selectedRepository}"

View File

@@ -86,6 +86,7 @@ export default class CommitItem extends LitElement {
}
@property({ type: String, reflect: true }) hash = '';
@property({ type: String }) cherrypick_hash = '';
@property({ type: String }) title = '';
@property({ type: Array }) authors = [];
@@ -102,16 +103,6 @@ export default class CommitItem extends LitElement {
<div></div>
<div class="item-people">
<div>
<span>committed in </span>
<a
href="https://github.com/${this.repository}/commit/${this.hash}"
target="_blank"
title="Open commit #${this.id} on GitHub"
>
${this.hash.substring(0, 9)}
</a>
</div>
<div class="item-authors">
<span>by </span>
${this.authors.map((author) => {
@@ -128,6 +119,29 @@ export default class CommitItem extends LitElement {
`;
})}
</div>
<div>
<span>committed in </span>
<a
href="https://github.com/${this.repository}/commit/${this.hash}"
target="_blank"
title="Open commit #${this.hash} on GitHub"
>
${this.hash.substring(0, 9)}
</a>
${(this.cherrypick_hash !== "" ? html`
<span> · </span>
<span>cherry-picked in </span>
<a
href="https://github.com/${this.repository}/commit/${this.cherrypick_hash}"
target="_blank"
title="Open commit #${this.cherrypick_hash} on GitHub"
>
${this.cherrypick_hash.substring(0, 9)}
</a>
` : null)}
</div>
</div>
</div>
</div>

View File

@@ -87,6 +87,7 @@ export default class PullRequestItem extends LitElement {
}
@property({ type: String, reflect: true }) id = '';
@property({ type: String }) cherrypick_id = '';
@property({ type: String }) title = '';
@property({ type: Array }) authors = [];
@property({ type: String }) url = '';
@@ -126,16 +127,6 @@ export default class PullRequestItem extends LitElement {
</div>
<div class="item-people">
<div>
<span>submitted as </span>
<a
href="${this.url}"
target="_blank"
title="Open PR #${this.id} on GitHub"
>
GH-${this.id}
</a>
</div>
<div class="item-authors">
<span>by </span>
${this.authors.map((author) => {
@@ -152,6 +143,29 @@ export default class PullRequestItem extends LitElement {
`;
})}
</div>
<div>
<span>submitted as </span>
<a
href="${this.url}"
target="_blank"
title="Open PR #${this.id} on GitHub"
>
GH-${this.id}
</a>
${(this.cherrypick_id !== "" ? html`
<span> · </span>
<span>cherry-picked in </span>
<a
href="https://github.com/${this.repository}/pull/${this.cherrypick_id}"
target="_blank"
title="Open PR #${this.cherrypick_id} on GitHub"
>
GH-${this.cherrypick_id}
</a>
` : null)}
</div>
</div>
</div>
</div>