mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-11-10 01:20:47 +03:00
Look up locked commit from remote commits as well
- also filters for unique commits, should really be done in the back end
This commit is contained in:
parent
066d520f1a
commit
ebc696ad26
@ -4,7 +4,7 @@
|
||||
import LargeDiffMessage from './LargeDiffMessage.svelte';
|
||||
import { computeAddedRemovedByHunk } from '$lib/utils/metrics';
|
||||
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 type { HunkSection, ContentSection } from '$lib/utils/fileSections';
|
||||
|
||||
@ -21,6 +21,9 @@
|
||||
$: minWidth = getGutterMinWidth(maxLineNumber);
|
||||
|
||||
const localCommits = isFileLocked ? getLocalCommits() : undefined;
|
||||
const remoteCommits = isFileLocked ? getRemoteCommits() : undefined;
|
||||
|
||||
const commits = isFileLocked ? ($localCommits || []).concat($remoteCommits || []) : undefined;
|
||||
let alwaysShow = false;
|
||||
|
||||
function getGutterMinWidth(max: number) {
|
||||
@ -52,10 +55,10 @@
|
||||
<div class="indicators text-base-11">
|
||||
<span class="added">+{added}</span>
|
||||
<span class="removed">-{removed}</span>
|
||||
{#if section.hunk.lockedTo && $localCommits}
|
||||
{#if section.hunk.lockedTo && commits}
|
||||
<div
|
||||
use:tooltip={{
|
||||
text: getLockText(section.hunk.lockedTo, $localCommits),
|
||||
text: getLockText(section.hunk.lockedTo, commits),
|
||||
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';
|
||||
|
||||
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 descriptions = lockedIds
|
||||
.filter(unique)
|
||||
.map((id) => {
|
||||
const commit = commits.find((commit) => commit.id == id);
|
||||
const shortCommitId = commit?.id.slice(0, 7);
|
||||
|
Loading…
Reference in New Issue
Block a user