use merge name & branch, remove description

This commit is contained in:
Nikita Galaiko 2023-07-14 16:08:26 +02:00
parent a985bc9769
commit b2fb64c071
4 changed files with 9 additions and 20 deletions

View File

@ -99,7 +99,6 @@ pub struct VirtualBranchFile {
#[serde(rename_all = "camelCase")]
pub struct VirtualBranchHunk {
pub id: String,
pub name: String,
pub diff: String,
pub modified_at: u128,
pub file_path: path::PathBuf,
@ -120,9 +119,7 @@ pub struct VirtualBranchHunk {
#[serde(rename_all = "camelCase")]
pub struct RemoteBranch {
sha: String,
branch: String,
name: String,
description: String,
last_commit_ts: u128,
first_commit_ts: u128,
ahead: u32,
@ -557,9 +554,7 @@ pub fn remote_branches(
branches.push(RemoteBranch {
sha: branch_oid.to_string(),
branch: branch_name.to_string(),
name: branch_name.to_string(),
description: "".to_string(),
last_commit_ts: max_time
.unwrap_or(0)
.try_into()
@ -584,9 +579,7 @@ pub fn remote_branches(
// this is a detached head
branches.push(RemoteBranch {
sha: "".to_string(),
branch: branch_name.to_string(),
name: branch_name.to_string(),
description: "".to_string(),
last_commit_ts: 0,
first_commit_ts: 0,
ahead: 0,
@ -1193,7 +1186,6 @@ fn hunks_by_filepath(
.iter()
.map(|hunk| VirtualBranchHunk {
id: format!("{}-{}", hunk.new_start, hunk.new_start + hunk.new_lines),
name: "".to_string(),
modified_at: get_mtime(&mut mtimes, &project_repository.path().join(file_path)),
file_path: file_path.clone(),
diff: hunk.diff.clone(),

View File

@ -1823,10 +1823,10 @@ fn test_detect_mergeable_branch() -> Result<()> {
assert!(branch2.mergeable);
assert_eq!(branch2.merge_conflicts.len(), 0);
let remotes = remote_branches(&gb_repo, &project_repository)?;
let remotes = remote_branches(&gb_repo, &project_repository).expect("failed to list remotes");
let remote1 = &remotes
.iter()
.find(|b| b.branch == "refs/remotes/origin/remote_branch")
.find(|b| b.name == "refs/remotes/origin/remote_branch")
.unwrap();
assert!(!remote1.mergeable);
assert_eq!(remote1.ahead, 1);
@ -1835,7 +1835,7 @@ fn test_detect_mergeable_branch() -> Result<()> {
let remote2 = &remotes
.iter()
.find(|b| b.branch == "refs/remotes/origin/remote_branch2")
.find(|b| b.name == "refs/remotes/origin/remote_branch2")
.unwrap();
assert!(remote2.mergeable);
assert_eq!(remote2.ahead, 2);

View File

@ -3,7 +3,6 @@ import { Type, Transform } from 'class-transformer';
export class Hunk {
id!: string;
name!: string;
diff!: string;
@Transform((obj) => {
return new Date(obj.value);
@ -52,9 +51,7 @@ export class Commit {
export class BranchData {
sha!: string;
branch!: string;
name!: string;
description!: string;
lastCommitTs!: number;
firstCommitTs!: number;
ahead!: number;

View File

@ -103,7 +103,7 @@
<!-- Your branches -->
<div
class="flex items-center justify-between border-b border-light-400 bg-light-100 py-1 px-2 pr-1 dark:border-dark-600 dark:bg-dark-800"
class="flex items-center justify-between border-b border-light-400 bg-light-100 px-2 py-1 pr-1 dark:border-dark-600 dark:bg-dark-800"
>
<div class="font-bold">Your branches</div>
<div class="flex h-4 w-4 justify-around">
@ -155,7 +155,7 @@
<!-- Remote branches -->
{#if remoteBranches}
<div
class="flex items-center justify-between border-b border-light-400 bg-light-100 py-1 px-2 pr-1 dark:border-dark-600 dark:bg-dark-800"
class="flex items-center justify-between border-b border-light-400 bg-light-100 px-2 py-1 pr-1 dark:border-dark-600 dark:bg-dark-800"
>
<div class="font-bold">Remote branches</div>
<div class="flex h-4 w-4 justify-around">
@ -174,11 +174,11 @@
<div
role="listitem"
on:contextmenu|preventDefault={(e) => remoteBranchContextMenu.openByMouse(e, branch)}
class="flex flex-col justify-between gap-1 border-b border-light-400 py-1 px-2 pt-2 dark:border-dark-600"
class="flex flex-col justify-between gap-1 border-b border-light-400 px-2 py-1 pt-2 dark:border-dark-600"
>
<div class="flex flex-row items-center gap-x-2">
<div class="text-light-600 dark:text-dark-200">
{#if branch.branch.match('refs/remotes')}
{#if branch.name.match('refs/remotes')}
<IconRemote class="h-4 w-4" />
{:else}
<IconGitBranch class="h-4 w-4" />
@ -186,9 +186,9 @@
</div>
<div
class="flex-grow cursor-pointer truncate text-black dark:text-white"
title={branch.branch}
title={branch.name}
>
{branch.branch
{branch.name
.replace('refs/remotes/', '')
.replace('origin/', '')
.replace('refs/heads/', '')}