Skip to content

Commit 5f6c159

Browse files
authored
Allow to easily see all the PRs I created recently (#6585)
Fixes #6191 Fixes #1927
1 parent 3070b6a commit 5f6c159

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

package.nls.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
]
2222
},
2323
"githubPullRequests.remotes.markdownDescription": "List of remotes, by name, to fetch pull requests from.",
24-
"githubPullRequests.queries.markdownDescription": "Specifies what queries should be used in the GitHub Pull Requests tree. All queries are made against **the currently opened repos**. Each query object has a `label` that will be shown in the tree and a search `query` using [GitHub search syntax](https://help.github.com/en/articles/understanding-the-search-syntax). The variable `${user}` can be used to specify the logged in user within a search. By default these queries define the categories \"Waiting For My Review\", \"Assigned To Me\" and \"Created By Me\". If you want to preserve these, make sure they are still in the array when you modify the setting.",
24+
"githubPullRequests.queries.markdownDescription": "Specifies what queries should be used in the GitHub Pull Requests tree. All queries are made against **the currently opened repos**. Each query object has a `label` that will be shown in the tree and a search `query` using [GitHub search syntax](https://help.github.com/en/articles/understanding-the-search-syntax). The following variables can be used: \n - `${user}` will resolve to the currently logged in user \n - `${owner}` will resolve to the owner of the current repository, ex. `microsoft` in `microsoft/vscode` \n - `${repository}` will resolve to the repository name, ex. `vscode` in `microsoft/vscode` \n - `${today-Nd}`, where `N` is the number of days ago, will resolve to a date, ex. `2025-01-04`. \n\n By default these queries define the categories \"Waiting For My Review\", \"Assigned To Me\" and \"Created By Me\". If you want to preserve these, make sure they are still in the array when you modify the setting.",
2525
"githubPullRequests.queries.label.description": "The label to display for the query in the Pull Requests tree",
2626
"githubPullRequests.queries.query.description": "The query used for searching pull requests.",
2727
"githubPullRequests.queries.waitingForMyReview": "Waiting For My Review",

src/github/utils.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,14 +1411,27 @@ export function sanitizeIssueTitle(title: string): string {
14111411
return title.replace(regex, '').trim().substring(0, 150).replace(/\s+/g, '-');
14121412
}
14131413

1414-
const VARIABLE_PATTERN = /\$\{(.*?)\}/g;
1414+
const SINCE_VALUE_PATTERN = /-([0-9]+)([d])/;
1415+
function computeSinceValue(sinceValue: string | undefined): string {
1416+
const match = sinceValue ? SINCE_VALUE_PATTERN.exec(sinceValue) : undefined;
1417+
const date = new Date();
1418+
if (match && match.length === 3 && match[2] === 'd') {
1419+
const dateOffset = parseInt(match[1]) * (24 * 60 * 60 * 1000);
1420+
date.setTime(date.getTime() - dateOffset);
1421+
}
1422+
const month = `${date.getMonth() + 1}`;
1423+
const day = `${date.getDate()}`;
1424+
return `${date.getFullYear()}-${month.padStart(2, '0')}-${day.padStart(2, '0')}`;
1425+
}
1426+
1427+
const VARIABLE_PATTERN = /\$\{([^-]*?)(-.*?)?\}/g;
14151428
export async function variableSubstitution(
14161429
value: string,
14171430
issueModel?: IssueModel,
14181431
defaults?: PullRequestDefaults,
14191432
user?: string,
14201433
): Promise<string> {
1421-
return value.replace(VARIABLE_PATTERN, (match: string, variable: string) => {
1434+
return value.replace(VARIABLE_PATTERN, (match: string, variable: string, extra: string) => {
14221435
let result: string;
14231436
switch (variable) {
14241437
case 'user':
@@ -1445,6 +1458,9 @@ export async function variableSubstitution(
14451458
case 'sanitizedLowercaseIssueTitle':
14461459
result = issueModel ? sanitizeIssueTitle(issueModel.title).toLowerCase() : match;
14471460
break;
1461+
case 'today':
1462+
result = computeSinceValue(extra);
1463+
break;
14481464
default:
14491465
result = match;
14501466
break;

0 commit comments

Comments
 (0)