diff --git a/README.md b/README.md index d9109f7..a6d993c 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,9 @@ By default, Violentmonkey will auto-update scripts from the original install loc - Reviews show build status (if it's empty, there isn't a merge commit or a build configured) - If a PR has bug work items associated with it, we add a label with the severity of such bugs (if SEV == 1 or 2) - Repo pull request listings will also link to the overall account-wide PR dashboard +- Each PR is annotated with source branch name. +- Target branch is hidden for PRs targeting `main` or `master`. +- Source and/or target branch name are abbreviated if they start with `users//`. - At [NI](https://www.ni.com), some labels get coloring (e.g. "bypass owners" gets a red background) - At [NI](https://www.ni.com), reviews are annotated with how long you've been on it if it's been over 1 weekday and you haven't voted or commented diff --git a/src/azdo-pr-dashboard.user.js b/src/azdo-pr-dashboard.user.js index f3d7208..846f565 100644 --- a/src/azdo-pr-dashboard.user.js +++ b/src/azdo-pr-dashboard.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name More Awesome Azure DevOps (userscript) -// @version 3.7.3 +// @version 3.8.0 // @author Alejandro Barreto (NI) // @description Makes general improvements to the Azure DevOps experience, particularly around pull requests. Also contains workflow improvements for NI engineers. // @license MIT @@ -76,15 +76,15 @@ 'agent-arbitration-status-off': 'Off', }); - eus.showTipOnce('release-2021-11-14', 'New in the AzDO userscript', ` -

Highlights from the 2021-11-14 update!

-

PR reviewers are now annotated with:

+ eus.showTipOnce('release-2024-04-24', 'New in the AzDO userscript', ` +

Highlights from the 2024-04-24 update!

+

Changes to the PR dashboard view:

+

See also other changes since our last update notification.


Comments, bugs, suggestions? File an issue on GitHub 🧡

`); @@ -1232,6 +1232,11 @@ .swal2-html-container { text-align: left; } + .swal2-html-container code { + background-color: rgba(0,0,0,.06); + padding: 0.2em 0.4em; + border-radius: 0.2em; + } .swal2-html-container li { list-style: disc; margin-left: 4ch; @@ -1472,6 +1477,7 @@ await annotateBugsOnPullRequestRow(row, pr); await annotateFileCountOnPullRequestRow(row, pr); await annotateBuildStatusOnPullRequestRow(row, pr); + annotateSourceBranchOnPullRequestRow(row, pr); if (votes.userVote === 0 && votes.missingVotes === 1 && votes.userIsRequired && !votes.userHasDeclined) { annotatePullRequestTitle(row, 'repos-pr-list-late-review-pill', 'Last Reviewer', 'Everyone is waiting on you!'); @@ -1492,6 +1498,7 @@ await annotateBugsOnPullRequestRow(row, pr); await annotateFileCountOnPullRequestRow(row, pr); await annotateBuildStatusOnPullRequestRow(row, pr); + annotateSourceBranchOnPullRequestRow(row, pr); } } @@ -1642,6 +1649,31 @@ annotatePullRequestLabel(row, 'build-status', tooltip, label); } + function annotateSourceBranchOnPullRequestRow(row, pr) { + if (!pr.lastMergeCommit) return; + + let sourceBranch = pr.sourceRefName.replace(/^refs\/heads\//, ''); + // Abbreviate e.g. 'users/kroeschl/foo' as 'u/k/foo' to save space + sourceBranch = sourceBranch.replace(/^users\/([^/])[^/]*\//, 'u/$1/'); + const secondary = row.querySelector('.secondary-text span'); + + if (['refs/heads/master', 'refs/heads/main'].includes(pr.targetRefName)) { + // Hide target branch and icon if it's main or master, which is very common + secondary.querySelector('.ms-Icon--OpenSource').remove(); // Branch icon + secondary.querySelector('.monospaced-xs').remove(); // Branch name + secondary.innerHTML = secondary.innerHTML.replace('into ', ''); + } else { + const targetBranch = pr.targetRefName.replace(/^refs\/heads\//, ''); + const targetBranchAbbrev = targetBranch.replace(/^users\/([^/])[^/]*\//, 'u/$1/'); + secondary.innerHTML = secondary.innerHTML.replace(targetBranch, targetBranchAbbrev); + } + + const sourceBranchAnnotation = `from + ${sourceBranch}`; + secondary.insertAdjacentHTML('beforeend', sourceBranchAnnotation); + } + function annotatePullRequestTitle(row, cssClass, message, tooltip) { const blockingAnnotation = `