-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improves overview branch autolinks #3957
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ import type { GitFileChangeShape } from '../../git/models/fileChange'; | |
import type { Issue } from '../../git/models/issue'; | ||
import type { GitPausedOperationStatus } from '../../git/models/pausedOperationStatus'; | ||
import type { PullRequest } from '../../git/models/pullRequest'; | ||
import type { GitBranchReference } from '../../git/models/reference'; | ||
import { RemoteResourceType } from '../../git/models/remoteResource'; | ||
import type { Repository, RepositoryFileSystemChangeEvent } from '../../git/models/repository'; | ||
import { RepositoryChange, RepositoryChangeComparisonMode } from '../../git/models/repository'; | ||
|
@@ -67,6 +68,7 @@ import type { IpcMessage } from '../protocol'; | |
import type { WebviewHost, WebviewProvider, WebviewShowingArgs } from '../webviewProvider'; | ||
import type { WebviewShowOptions } from '../webviewsController'; | ||
import type { | ||
BranchIssueLink, | ||
BranchRef, | ||
CollapseSectionParams, | ||
DidChangeRepositoriesParams, | ||
|
@@ -332,6 +334,7 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe | |
registerCommand('gitlens.home.continuePausedOperation', this.continuePausedOperation, this), | ||
registerCommand('gitlens.home.abortPausedOperation', this.abortPausedOperation, this), | ||
registerCommand('gitlens.home.openRebaseEditor', this.openRebaseEditor, this), | ||
registerCommand('gitlens.home.unlinkIssue', this.unlinkIssue, this), | ||
]; | ||
} | ||
|
||
|
@@ -545,6 +548,35 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe | |
}); | ||
} | ||
|
||
private async unlinkIssue({ issue, reference }: { reference: GitBranchReference; issue: BranchIssueLink }) { | ||
const skipPrompt = this.container.storage.get('autolinks:branches:ignore:skipPrompt') || undefined; | ||
const item = | ||
skipPrompt ?? | ||
(await window.showWarningMessage( | ||
`This action will unlink the issue ${issue.url} from the branch ${reference.name} forever`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not a fan of something that cannot be undone like this. I think we need a broader discussion on how we want to handle issue association and dissociation and how autolinks fit into that mix, in a way that prevents anyone from getting stuck into a state they cannot easily back out from. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can be discussed on today's daily standup. @justinrobots |
||
{ | ||
modal: true, | ||
}, | ||
`OK`, | ||
`OK, Don't ask again`, | ||
)); | ||
if (!item) { | ||
return; | ||
} | ||
if (item === `OK, Don't ask again`) { | ||
void this.container.storage.store('autolinks:branches:ignore:skipPrompt', true); | ||
} | ||
const prev = this.container.storage.get('autolinks:branches:ignore') ?? {}; | ||
const refId = reference.id ?? `${reference.repoPath}/${reference.remote}/${reference.ref}`; | ||
await this.container.storage | ||
.store('autolinks:branches:ignore', { | ||
...prev, | ||
[refId]: [...(prev[refId] ?? []), issue.url], | ||
}) | ||
.catch(); | ||
void this.host.notify(DidChangeRepositoryWip, undefined); | ||
} | ||
|
||
private async createCloudPatch(ref: BranchRef) { | ||
const status = await this.container.git.status(ref.repoPath).getStatus(); | ||
if (status == null) return; | ||
|
@@ -1357,11 +1389,12 @@ function getOverviewBranchesCore( | |
for (const branch of branches) { | ||
const wt = worktreesByBranch.get(branch.id); | ||
|
||
const ignored = container.storage.get('autolinks:branches:ignore')?.[branch.id]; | ||
const timestamp = branch.date?.getTime(); | ||
|
||
if (isPro === true) { | ||
prPromises.set(branch.id, getPullRequestInfo(container, branch, launchpadPromise)); | ||
autolinkPromises.set(branch.id, branch.getEnrichedAutolinks()); | ||
autolinkPromises.set(branch.id, branch.getEnrichedAutolinks(ignored)); | ||
issuePromises.set( | ||
branch.id, | ||
getAssociatedIssuesForBranch(container, branch).then(issues => issues.value), | ||
|
@@ -1472,6 +1505,8 @@ async function getAutolinkIssuesInfo(links: Map<string, EnrichedAutolink> | unde | |
title: issue.title, | ||
url: issue.url, | ||
state: issue.state, | ||
type: issue.type, | ||
isAutolink: true, | ||
}; | ||
}), | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain what "non-prefixed" means a bit so I can understand?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
non-prefixed refset is required to parse branch name autolinks and mean that we're trying to search issue keys in any numbers with no prefixes. For example, we can search issues with prefixes
#
orgh
for github in commit messages, but for the branch names the issue keys can be non-prefixed - just numbers. like in current branch namebugs/3956-pr-autolinks-are-rendered-in-issues-section
- the issue key is just a number without any prefixes