Skip to content

Commit 2841f74

Browse files
Copilotalexr00
andauthored
Auto-assign current user to issues created from TODO/FIXME comments (#8262)
* Initial plan * Initial analysis of create issue feature Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> * Add assignToMeOnCreate setting and implement auto-assignment for issues created from TODO/FIXME Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> * Remove unrelated change from type definitions file Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> * Address code review feedback: improve error logging and explicitly pass GitHub repository Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> * Remove setting and auto-assign if user is assignable in repo Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent 0f1dd96 commit 2841f74

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/issues/issueFeatureRegistrar.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,36 @@ export class IssueFeatureRegistrar extends Disposable {
10791079
if (matches && matches.length === 2 && (await this._stateManager.getUserMap(document.uri)).has(matches[1])) {
10801080
assignees = [matches[1]];
10811081
}
1082+
1083+
// Auto-assign to current user if they are assignable in the repository
1084+
const folderManager = this.manager.getManagerForFile(document.uri);
1085+
if (folderManager) {
1086+
try {
1087+
// Get the GitHub repository for the document
1088+
const githubRepository = folderManager.gitHubRepositories[0];
1089+
if (githubRepository) {
1090+
const currentUser = await folderManager.getCurrentUser(githubRepository);
1091+
if (currentUser?.login) {
1092+
// Check if the current user is assignable in this repository
1093+
const assignableUsers = await folderManager.getAssignableUsers();
1094+
const assignableUsersForRemote = assignableUsers[githubRepository.remote.remoteName] || [];
1095+
const isAssignable = assignableUsersForRemote.some(user => user.login === currentUser.login);
1096+
if (isAssignable) {
1097+
// Add current user to assignees if not already included
1098+
if (!assignees) {
1099+
assignees = [currentUser.login];
1100+
} else if (!assignees.includes(currentUser.login)) {
1101+
assignees.push(currentUser.login);
1102+
}
1103+
}
1104+
}
1105+
}
1106+
} catch (error) {
1107+
// If we can't get the current user or assignable users, just continue without auto-assignment
1108+
Logger.debug(`Failed to auto-assign current user: ${error}`, IssueFeatureRegistrar.ID);
1109+
}
1110+
}
1111+
10821112
let title: string | undefined;
10831113
const body: string | undefined = await this.createTodoIssueBody(newIssue, issueBody);
10841114

0 commit comments

Comments
 (0)