mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-18 23:02:31 +03:00
Merge pull request #3609 from gitbutlerapp/Fix-bug-where-sometimes-lock-commit-info-is-unavailable
Look up locked commit from remote commits as well
This commit is contained in:
commit
cac2b6a80b
@ -4,7 +4,7 @@
|
|||||||
import LargeDiffMessage from './LargeDiffMessage.svelte';
|
import LargeDiffMessage from './LargeDiffMessage.svelte';
|
||||||
import { computeAddedRemovedByHunk } from '$lib/utils/metrics';
|
import { computeAddedRemovedByHunk } from '$lib/utils/metrics';
|
||||||
import { tooltip } from '$lib/utils/tooltip';
|
import { tooltip } from '$lib/utils/tooltip';
|
||||||
import { getLocalCommits } from '$lib/vbranches/contexts';
|
import { getLocalCommits, getRemoteCommits } from '$lib/vbranches/contexts';
|
||||||
import { getLockText } from '$lib/vbranches/tooltip';
|
import { getLockText } from '$lib/vbranches/tooltip';
|
||||||
import type { HunkSection, ContentSection } from '$lib/utils/fileSections';
|
import type { HunkSection, ContentSection } from '$lib/utils/fileSections';
|
||||||
|
|
||||||
@ -21,6 +21,9 @@
|
|||||||
$: minWidth = getGutterMinWidth(maxLineNumber);
|
$: minWidth = getGutterMinWidth(maxLineNumber);
|
||||||
|
|
||||||
const localCommits = isFileLocked ? getLocalCommits() : undefined;
|
const localCommits = isFileLocked ? getLocalCommits() : undefined;
|
||||||
|
const remoteCommits = isFileLocked ? getRemoteCommits() : undefined;
|
||||||
|
|
||||||
|
const commits = isFileLocked ? ($localCommits || []).concat($remoteCommits || []) : undefined;
|
||||||
let alwaysShow = false;
|
let alwaysShow = false;
|
||||||
|
|
||||||
function getGutterMinWidth(max: number) {
|
function getGutterMinWidth(max: number) {
|
||||||
@ -52,10 +55,10 @@
|
|||||||
<div class="indicators text-base-11">
|
<div class="indicators text-base-11">
|
||||||
<span class="added">+{added}</span>
|
<span class="added">+{added}</span>
|
||||||
<span class="removed">-{removed}</span>
|
<span class="removed">-{removed}</span>
|
||||||
{#if section.hunk.lockedTo && $localCommits}
|
{#if section.hunk.lockedTo && commits}
|
||||||
<div
|
<div
|
||||||
use:tooltip={{
|
use:tooltip={{
|
||||||
text: getLockText(section.hunk.lockedTo, $localCommits),
|
text: getLockText(section.hunk.lockedTo, commits),
|
||||||
delay: 500
|
delay: 500
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
4
app/src/lib/utils/filters.ts
Normal file
4
app/src/lib/utils/filters.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
// If a value occurs > 1 times then all but one will fail this condition.
|
||||||
|
export function unique(value: any, index: number, array: any[]) {
|
||||||
|
return array.indexOf(value) === index;
|
||||||
|
}
|
@ -1,3 +1,4 @@
|
|||||||
|
import { unique } from '$lib/utils/filters';
|
||||||
import type { Commit } from './types';
|
import type { Commit } from './types';
|
||||||
|
|
||||||
export function getLockText(commitId: string[] | string, commits: Commit[]): string {
|
export function getLockText(commitId: string[] | string, commits: Commit[]): string {
|
||||||
@ -6,6 +7,7 @@ export function getLockText(commitId: string[] | string, commits: Commit[]): str
|
|||||||
const lockedIds = typeof commitId == 'string' ? [commitId] : (commitId as string[]);
|
const lockedIds = typeof commitId == 'string' ? [commitId] : (commitId as string[]);
|
||||||
|
|
||||||
const descriptions = lockedIds
|
const descriptions = lockedIds
|
||||||
|
.filter(unique)
|
||||||
.map((id) => {
|
.map((id) => {
|
||||||
const commit = commits.find((commit) => commit.id == id);
|
const commit = commits.find((commit) => commit.id == id);
|
||||||
const shortCommitId = commit?.id.slice(0, 7);
|
const shortCommitId = commit?.id.slice(0, 7);
|
||||||
|
Loading…
Reference in New Issue
Block a user