Skip to content

Azure DevOps Work Item autolinks point to wrong project when Work Item belongs to a different project #4776

@danielasher115

Description

@danielasher115

Description

When a commit message contains a Work Item reference (e.g., #1234), the autolink URL incorrectly uses the repository's project in the URL path. However, Azure DevOps Work Items are organization-scoped and can belong to any project within the organization, not just the project containing the repository.

Expected Behavior

Work Item autolinks should use an organization-level URL (e.g., https://dev.azure.com/org/_workitems/edit/1234) which correctly redirects to the Work Item regardless of which project it belongs to.

Actual Behavior

Work Item autolinks currently use a project-scoped URL (e.g., https://dev.azure.com/org/ProjectA/_workitems/edit/1234), which fails or shows the wrong item when the Work Item actually belongs to a different project (e.g., ProjectB).

Steps to Reproduce

  1. Have an Azure DevOps organization with multiple projects
  2. Create a Work Item in Project B
  3. Make a commit in a repository in Project A that references the Work Item (e.g., Fixes #1234)
  4. Hover over the commit message in GitLens
  5. Click the Work Item link

Verification steps

Make sure that the following project base urls form the following patterns:

  • https://{org}.visualstudio.com/{project}/_git/{repo} -> https://{org}.visualstudio.com/_workitems/edit/<num>
  • https://dev.azure.com/{org}/{project}/_git/{repo} -> https://dev.azure.com/{org}/_workitems/edit/<num>
  • https://{selfhosted-host}/{collection}/{project}/_git/{repo} -> https://{selfhosted-host}/{collection}/_workitems/edit/<num>

Also make sure that AzureDevOps redirects it to the right issue or PR:

  • https://{org}.visualstudio.com/_workitems/edit/{num} -> https://{org}.visualstudio.com/{project}/_workitems/edit/{num}
  • https://dev.azure.com/{org}/_workitems/edit/{num} -> https://dev.azure.com/{org}/{project}/_workitems/edit/{num}
  • https://{selfhosted-host}/{collection}/_workitems/edit/<num> -> https://{selfhosted-host}/{collection}/{project}/_workitems/edit/{num}

GitLens Version

v17.7.1

VS Code Version

Version: 2.1.47 (user setup)
VSCode Version: 1.105.1
Commit: 2d3ce3499c15efd55b6b8538ea255eb7ba4266b0
Date: 2025-12-04T02:31:50.567Z
Electron: 37.7.0
Chromium: 138.0.7204.251
Node.js: 22.20.0
V8: 13.8.258.32-electron.0
OS: Windows_NT x64 10.0.26200

Git Version

git version 2.50.1

Logs, Screenshots, Screen Captures, etc

No response

Metadata

Metadata

Assignees

Labels

pending-releaseResolved but not yet released to the stable editionverified ✔Verified

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions