Skip to content

Commit ac9f504

Browse files
Copilotalexr00
andcommitted
Add assignToMeOnCreate setting and implement auto-assignment for issues created from TODO/FIXME
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent c892583 commit ac9f504

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,11 @@
646646
"default": "number",
647647
"description": "%githubIssues.createInsertFormat.description%"
648648
},
649+
"githubIssues.assignToMeOnCreate": {
650+
"type": "boolean",
651+
"default": false,
652+
"description": "%githubIssues.assignToMeOnCreate.description%"
653+
},
649654
"githubIssues.issueCompletions.enabled": {
650655
"type": "boolean",
651656
"default": true,

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
"githubIssues.createIssueTriggers.items": "String that enables the 'Create issue from comment' code action. Should not contain whitespace.",
108108
"githubPullRequests.codingAgent.codeLens.description": "Show the 'Delegate to agent' CodeLens actions above TODO comments for delegating to coding agent.",
109109
"githubIssues.createInsertFormat.description": "Controls whether an issue number (ex. #1234) or a full url (ex. https://github.com/owner/name/issues/1234) is inserted when the Create Issue code action is run.",
110+
"githubIssues.assignToMeOnCreate.description": "When enabled, automatically assigns new issues created from TODO/FIXME comments to yourself.",
110111
"githubIssues.issueCompletions.enabled.description": "Controls whether completion suggestions are shown for issues.",
111112
"githubIssues.userCompletions.enabled.description": "Controls whether completion suggestions are shown for users.",
112113
"githubIssues.ignoreCompletionTrigger.description": "Languages that the '#' character should not be used to trigger issue completion suggestions.",

src/common/settingKeys.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export const USER_COMPLETIONS = 'userCompletions';
4747
export const ENABLED = 'enabled';
4848
export const IGNORE_USER_COMPLETION_TRIGGER = 'ignoreUserCompletionTrigger';
4949
export const CREATE_INSERT_FORMAT = 'createInsertFormat';
50+
export const ASSIGN_TO_ME_ON_CREATE = 'assignToMeOnCreate';
5051
export const ISSUE_BRANCH_TITLE = 'issueBranchTitle';
5152
export const USE_BRANCH_FOR_ISSUES = 'useBranchForIssues';
5253
export const WORKING_ISSUE_FORMAT_SCM = 'workingIssueFormatScm';

src/issues/issueFeatureRegistrar.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { Disposable } from '../common/lifecycle';
1515
import Logger from '../common/logger';
1616
import {
1717
ALWAYS_PROMPT_FOR_NEW_ISSUE_REPO,
18+
ASSIGN_TO_ME_ON_CREATE,
1819
CREATE_INSERT_FORMAT,
1920
ENABLED,
2021
ISSUE_COMPLETIONS,
@@ -1000,6 +1001,30 @@ export class IssueFeatureRegistrar extends Disposable {
10001001
if (matches && matches.length === 2 && (await this._stateManager.getUserMap(document.uri)).has(matches[1])) {
10011002
assignees = [matches[1]];
10021003
}
1004+
1005+
// Check if we should auto-assign to the current user
1006+
const assignToMe = vscode.workspace.getConfiguration(ISSUES_SETTINGS_NAMESPACE).get<boolean>(ASSIGN_TO_ME_ON_CREATE, false);
1007+
if (assignToMe) {
1008+
// Get the folder manager to access the current user
1009+
const folderManager = this.manager.getManagerForFile(document.uri);
1010+
if (folderManager) {
1011+
try {
1012+
const currentUser = await folderManager.getCurrentUser();
1013+
if (currentUser?.login) {
1014+
// Add current user to assignees if not already included
1015+
if (!assignees) {
1016+
assignees = [currentUser.login];
1017+
} else if (!assignees.includes(currentUser.login)) {
1018+
assignees.push(currentUser.login);
1019+
}
1020+
}
1021+
} catch (error) {
1022+
// If we can't get the current user, just continue without auto-assignment
1023+
Logger.debug(`Failed to get current user for auto-assignment: ${error}`, IssueFeatureRegistrar.ID);
1024+
}
1025+
}
1026+
}
1027+
10031028
let title: string | undefined;
10041029
const body: string | undefined = await this.createTodoIssueBody(newIssue, issueBody);
10051030

0 commit comments

Comments
 (0)