Skip to content

Commit 54f340b

Browse files
Copilotalexr00
andcommitted
Remove setting and auto-assign if user is assignable in repo
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent 9496b28 commit 54f340b

File tree

4 files changed

+21
-25
lines changed

4 files changed

+21
-25
lines changed

package.json

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

package.nls.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@
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.",
111110
"githubIssues.issueCompletions.enabled.description": "Controls whether completion suggestions are shown for issues.",
112111
"githubIssues.userCompletions.enabled.description": "Controls whether completion suggestions are shown for users.",
113112
"githubIssues.ignoreCompletionTrigger.description": "Languages that the '#' character should not be used to trigger issue completion suggestions.",

src/common/settingKeys.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ 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';
5150
export const ISSUE_BRANCH_TITLE = 'issueBranchTitle';
5251
export const USE_BRANCH_FOR_ISSUES = 'useBranchForIssues';
5352
export const WORKING_ISSUE_FORMAT_SCM = 'workingIssueFormatScm';

src/issues/issueFeatureRegistrar.ts

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ 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,
1918
CREATE_INSERT_FORMAT,
2019
ENABLED,
2120
ISSUE_COMPLETIONS,
@@ -1002,28 +1001,32 @@ export class IssueFeatureRegistrar extends Disposable {
10021001
assignees = [matches[1]];
10031002
}
10041003

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-
// Get the GitHub repository for the document to ensure we get the correct user
1013-
const githubRepository = folderManager.gitHubRepositories[0];
1004+
// Auto-assign to current user if they are assignable in the repository
1005+
const folderManager = this.manager.getManagerForFile(document.uri);
1006+
if (folderManager) {
1007+
try {
1008+
// Get the GitHub repository for the document
1009+
const githubRepository = folderManager.gitHubRepositories[0];
1010+
if (githubRepository) {
10141011
const currentUser = await folderManager.getCurrentUser(githubRepository);
10151012
if (currentUser?.login) {
1016-
// Add current user to assignees if not already included
1017-
if (!assignees) {
1018-
assignees = [currentUser.login];
1019-
} else if (!assignees.includes(currentUser.login)) {
1020-
assignees.push(currentUser.login);
1013+
// Check if the current user is assignable in this repository
1014+
const assignableUsers = await folderManager.getAssignableUsers();
1015+
const assignableUsersForRemote = assignableUsers[githubRepository.remote.remoteName] || [];
1016+
const isAssignable = assignableUsersForRemote.some(user => user.login === currentUser.login);
1017+
if (isAssignable) {
1018+
// Add current user to assignees if not already included
1019+
if (!assignees) {
1020+
assignees = [currentUser.login];
1021+
} else if (!assignees.includes(currentUser.login)) {
1022+
assignees.push(currentUser.login);
1023+
}
10211024
}
10221025
}
1023-
} catch (error) {
1024-
// If we can't get the current user, just continue without auto-assignment
1025-
Logger.debug('Failed to get current user for auto-assignment', IssueFeatureRegistrar.ID, error);
10261026
}
1027+
} catch (error) {
1028+
// If we can't get the current user or assignable users, just continue without auto-assignment
1029+
Logger.debug(`Failed to auto-assign current user: ${error}`, IssueFeatureRegistrar.ID);
10271030
}
10281031
}
10291032

0 commit comments

Comments
 (0)