Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 9, 2025

This PR adds support for variable substitution in PR title and description templates. Users can now use variables like ${issueNumberLabel}, ${issueTitle}, ${issueNumber}, ${user}, ${repository}, and ${owner} in their PR description templates, and they will be automatically replaced with actual values when creating a PR.

Changes Made

  • Variable Substitution: Modified getTitleAndDescription() method in src/github/createPRViewProvider.ts to apply variable substitution to both PR title and description using the existing variableSubstitution() function
  • Issue Context: Leverages the activeIssue property from FolderRepositoryManager to provide issue context for variable replacement
  • Error Handling: Added try-catch block around getCurrentUser() call to prevent errors from breaking PR creation flow
  • Tests: Added comprehensive unit tests for the variableSubstitution() function in src/test/github/utils.test.ts

Supported Variables

  • ${issueNumberLabel} - Issue reference (e.g., #123 or owner/repo#123)
  • ${issueNumber} - Just the issue number (e.g., 123)
  • ${issueTitle} - The issue title
  • ${user} - Current user's username
  • ${repository} - Repository name
  • ${owner} - Repository owner

Example

Template:

Closes ${issueNumberLabel}

## Changes
Working on ${issueTitle}

Expands to:

Closes #123

## Changes
Working on Fix bug in parser

Testing

  • ✅ All linting checks passed
  • ✅ All hygiene checks passed
  • ✅ Code review completed
  • ✅ Security scan (CodeQL) passed with 0 vulnerabilities
  • ✅ Unit tests added and compile successfully

This implementation makes it easier to track and link pull requests to the issues they're associated with, especially when using many small issues in a ticket-like way.

Original prompt

This section details on the original issue you should resolve

<issue_title>PR description templates should support templating</issue_title>
<issue_description>

We want to automatically link pull requests to the issues they're associated with. The obvious answer is to include Closes ${issueNumberLabel} in the PR description template.

But it appears that the PR description templates do not support template syntax.

Implementing this would make it easier to track many small issues being used in a ticket-like way.</issue_description>

<agent_instructions>When using a template for the PR title or description, run the variable substitution. </agent_instructions>

Comments on the Issue (you are @copilot in this section)

@alexr00 > PR description template

How are you configuring your PR description template?</comment_new>
<comment_new>@alexr00
Got it, thanks. Are you using the "start working on an issue" flow in the extension?</comment_new>
<comment_new>@alexr00
Thanks for the screen shots! We should be able to add support for this.</comment_new>
<comment_new>@alexr00
Adding a 👍 to the original post in the issue helps us easily see which feature requests are most asked for!</comment_new>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI self-assigned this Dec 9, 2025
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Copy link
Member

@alexr00 alexr00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot continue

Copilot AI and others added 3 commits December 18, 2025 13:44
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 18, 2025

@copilot continue

I've completed the implementation of variable substitution for PR description templates. The changes enable templates to use variables like ${issueNumberLabel}, ${issueTitle}, ${issueNumber}, ${user}, ${repository}, and ${owner} which will be automatically replaced when creating a PR.

Key changes in commit 1c30005:

  • Added variable substitution to both title and description in getTitleAndDescription()
  • Uses the active issue context when available
  • Includes error handling for user lookup failures
  • Added comprehensive tests for the functionality

All linting, hygiene checks, code review, and security scans passed successfully.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • update.code.visualstudio.com
    • Triggering command: /opt/hostedtoolcache/node/20.19.6/x64/bin/node node ./out/src/test/runTests.js --grep variableSubstitution (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Add support for templating in PR description templates Add support for variable substitution in PR description templates Dec 18, 2025
Copilot AI requested a review from alexr00 December 18, 2025 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PR description templates should support templating

2 participants