Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

![Label Suggestion](documentation/changelog/0.18.0/label-suggestion.gif)
- Hovers work for issues formatted as GH-123.
- The `githubIssues.workingIssueBranch` setting can take the new variable `${sanitizedIssueTitle}`.
- The `githubIssues.issueBranchTitle` setting can take the new variable `${sanitizedIssueTitle}`.
- If you have uncommitted changes in your issue branch when you try to create a pull request, you'll be prompted to commit them.

![Commit Prompt](documentation/changelog/0.18.0/commit-prompt.png)
Expand Down
2 changes: 1 addition & 1 deletion documentation/IssueFeatures.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,5 @@ From the issues view you can start working on an issue. This creates a branch, p

![Start Working](images/startWorking.gif)

**Start Working** is customizable. If you don't want a branch to be created, use `"githubIssues.useBranchForIssues": "off"`. If you always want to be prompted to enter the name of the branch use the `"prompt"` option of the setting. If you have a different naming scheme for your branches you can use `"githubIssues.workingIssueBranch": "${user}/issue${issueNumber}"` to configure it.
**Start Working** is customizable. If you don't want a branch to be created, use `"githubIssues.useBranchForIssues": "off"`. If you always want to be prompted to enter the name of the branch use the `"prompt"` option of the setting. If you have a different naming scheme for your branches you can use `"githubIssues.issueBranchTitle": "${user}/issue${issueNumber}"` to configure it.

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,11 @@
"description": "Languages that the '@' character should not be used to trigger user completion suggestions."
},
"githubIssues.workingIssueBranch": {
"type": "string",
"deprecationMessage": "This setting is replaced by the better named setting githubIssues.issueBranchTitle and may be removed in the future.",
"description": "Advanced settings for the name of the branch that is created when you start working on an issue. ${user} will be replace with the currently logged in username and ${issueNumber} will be replaced with the current issue number. You can also use ${sanitizedIssueTitle}."
},
"githubIssues.issueBranchTitle": {
"type": "string",
"default": "${user}/issue${issueNumber}",
"description": "Advanced settings for the name of the branch that is created when you start working on an issue. ${user} will be replace with the currently logged in username and ${issueNumber} will be replaced with the current issue number. You can also use ${sanitizedIssueTitle}."
Expand All @@ -284,7 +289,7 @@
"A prompt will show for setting the name of the branch that will be created and checked out."
],
"default": "on",
"description": "Determines whether a branch should be checked out when working on an issue. To configure the name of the branch, set `githubIssues.workingIssueBranch`."
"description": "Determines whether a branch should be checked out when working on an issue. To configure the name of the branch, set `githubIssues.issueBranchTitle`."
},
"githubIssues.issueCompletionFormatScm": {
"type": "string",
Expand Down
24 changes: 22 additions & 2 deletions src/issues/currentIssue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { PullRequestManager, PullRequestDefaults } from '../github/pullRequestManager';
import { IssueModel } from '../github/issueModel';
import * as vscode from 'vscode';
import { ISSUES_CONFIGURATION, variableSubstitution, BRANCH_NAME_CONFIGURATION, getIssueNumberLabel, BRANCH_CONFIGURATION, SCM_MESSAGE_CONFIGURATION } from './util';
import { ISSUES_CONFIGURATION, variableSubstitution, BRANCH_NAME_CONFIGURATION, getIssueNumberLabel, BRANCH_CONFIGURATION, SCM_MESSAGE_CONFIGURATION, BRANCH_NAME_CONFIGURATION_DEPRECATED } from './util';
import { Repository } from '../typings/git';
import { StateManager, IssueState } from './stateManager';

Expand Down Expand Up @@ -100,6 +100,26 @@ export class CurrentIssue {
return this.user;
}

// TODO: #1972 Delete the deprecated setting
private async ensureBranchTitleConfigMigrated(): Promise<string> {
const configuration = vscode.workspace.getConfiguration(ISSUES_CONFIGURATION);
const deprecatedConfigInspect = configuration.inspect(BRANCH_NAME_CONFIGURATION_DEPRECATED);
function migrate(value: any, target: vscode.ConfigurationTarget) {
configuration.update(BRANCH_NAME_CONFIGURATION, value, target);
configuration.update(BRANCH_NAME_CONFIGURATION_DEPRECATED, undefined, target);
}
if (deprecatedConfigInspect?.globalValue) {
migrate(deprecatedConfigInspect.globalValue, vscode.ConfigurationTarget.Global);
}
if (deprecatedConfigInspect?.workspaceValue) {
migrate(deprecatedConfigInspect.workspaceValue, vscode.ConfigurationTarget.Workspace);
}
if (deprecatedConfigInspect?.workspaceFolderValue) {
migrate(deprecatedConfigInspect.workspaceFolderValue, vscode.ConfigurationTarget.WorkspaceFolder);
}
return vscode.workspace.getConfiguration(ISSUES_CONFIGURATION).get<string>(BRANCH_NAME_CONFIGURATION) ?? this.getBasicBranchName(await this.getUser());
}

private async createIssueBranch(): Promise<void> {
const createBranchConfig = this.shouldPromptForBranch ? 'prompt' : <string>vscode.workspace.getConfiguration(ISSUES_CONFIGURATION).get(BRANCH_CONFIGURATION);
if (createBranchConfig === 'off') {
Expand All @@ -109,7 +129,7 @@ export class CurrentIssue {
this._branchName = this.shouldPromptForBranch ? undefined : state.branch;
if (!this._branchName) {
if (createBranchConfig === 'on') {
const branchNameConfig = <string>vscode.workspace.getConfiguration(ISSUES_CONFIGURATION).get(BRANCH_NAME_CONFIGURATION);
const branchNameConfig = await this.ensureBranchTitleConfigMigrated();
this._branchName = await variableSubstitution(branchNameConfig, this.issue, undefined, await this.getUser());
} else {
this._branchName = await vscode.window.showInputBox({ placeHolder: `issue${this.issueModel.number}`, prompt: 'Enter the label for the new branch.' });
Expand Down
2 changes: 1 addition & 1 deletion src/issues/stateManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class StateManager {
public onRefreshCacheNeeded: vscode.Event<void> = this._onRefreshCacheNeeded.event;
private _onDidChangeIssueData: vscode.EventEmitter<void> = new vscode.EventEmitter();
public onDidChangeIssueData: vscode.Event<void> = this._onDidChangeIssueData.event;
private _queries: { label: string, query: string }[];
private _queries: { label: string, query: string }[] = [];

private _currentIssue: CurrentIssue | undefined;
private _onDidChangeCurrentIssue: vscode.EventEmitter<void> = new vscode.EventEmitter();
Expand Down
3 changes: 2 additions & 1 deletion src/issues/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ export type ParsedIssue = { owner: string | undefined, name: string | undefined,
export const ISSUES_CONFIGURATION: string = 'githubIssues';
export const QUERIES_CONFIGURATION = 'queries';
export const DEFAULT_QUERY_CONFIGURATION = 'default';
export const BRANCH_NAME_CONFIGURATION = 'workingIssueBranch';
export const BRANCH_NAME_CONFIGURATION_DEPRECATED = 'workingIssueBranch';
export const BRANCH_NAME_CONFIGURATION = 'issueBranchTitle';
export const BRANCH_CONFIGURATION = 'useBranchForIssues';
export const SCM_MESSAGE_CONFIGURATION = 'workingIssueFormatScm';

Expand Down
1 change: 0 additions & 1 deletion src/test/view/prsTree.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ describe('GitHub Pull Requests view', function () {
assert.strictEqual(onlyItem.command, undefined);
});


it('opens the viewlet and displays the default categories', async function () {
const repository = new MockRepository();
repository.addRemote('origin', 'git@github.com:aaa/bbb');
Expand Down