Merge pull request #784 from gitbutlerapp/show-recent-commits

Adding recent commits to the branch base thing at the bottom
This commit is contained in:
Scott Chacon 2023-07-21 15:57:41 +02:00 committed by GitHub
commit c57d5759de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 193 additions and 85 deletions

View File

@ -3,7 +3,7 @@ on: [push]
jobs:
lint-frontend:
runs-on: ubuntu-latest
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v3
@ -25,7 +25,7 @@ jobs:
pnpm lint-ci
check-frontend:
runs-on: ubuntu-latest
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v3
@ -47,7 +47,7 @@ jobs:
pnpm check
unittest-frontend:
runs-on: ubuntu-latest
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v3
@ -69,7 +69,7 @@ jobs:
pnpm test
lint-rust:
runs-on: ubuntu-latest
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v3
@ -96,7 +96,7 @@ jobs:
story:
runs-on: ubuntu-latest
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v3
@ -133,7 +133,7 @@ jobs:
run: pnpm story:build
test:
runs-on: ubuntu-latest
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v3

207
butler/Cargo.lock generated
View File

@ -28,17 +28,6 @@ dependencies = [
"cpufeatures",
]
[[package]]
name = "ahash"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47"
dependencies = [
"getrandom 0.2.10",
"once_cell",
"version_check",
]
[[package]]
name = "ahash"
version = "0.8.3"
@ -50,15 +39,6 @@ dependencies = [
"version_check",
]
[[package]]
name = "aho-corasick"
version = "0.7.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac"
dependencies = [
"memchr",
]
[[package]]
name = "aho-corasick"
version = "1.0.2"
@ -1219,20 +1199,6 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25c7df09945d65ea8d70b3321547ed414bbc540aad5bac6883d021b970f35b04"
[[package]]
name = "fastfield_codecs"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "374a3a53c1bd5fb31b10084229290eafb0a05f260ec90f1f726afffda4877a8a"
dependencies = [
"fastdivide",
"itertools",
"log",
"ownedbytes",
"tantivy-bitpacker",
"tantivy-common",
]
[[package]]
name = "fastrand"
version = "1.9.0"
@ -1347,13 +1313,13 @@ dependencies = [
]
[[package]]
name = "fs2"
version = "0.4.3"
name = "fs4"
version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213"
checksum = "2eeb4ed9e12f43b7fa0baae3f9cdda28352770132ef2e09a23760c29cae8bd47"
dependencies = [
"libc",
"winapi",
"rustix 0.38.4",
"windows-sys 0.48.0",
]
[[package]]
@ -1770,7 +1736,7 @@ version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1391ab1f92ffcc08911957149833e682aa3fe252b9f45f966d2ef972274c97df"
dependencies = [
"aho-corasick 1.0.2",
"aho-corasick",
"bstr 1.6.0",
"fnv",
"log",
@ -1878,8 +1844,14 @@ name = "hashbrown"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
[[package]]
name = "hashbrown"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e"
dependencies = [
"ahash 0.7.6",
"ahash",
]
[[package]]
@ -1888,7 +1860,7 @@ version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a"
dependencies = [
"ahash 0.8.3",
"ahash",
"allocator-api2",
]
@ -2528,18 +2500,18 @@ dependencies = [
[[package]]
name = "lru"
version = "0.7.8"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e999beba7b6e8345721bd280141ed958096a2e4abdf74f67ff4ce49b4b54e47a"
checksum = "718e8fae447df0c7e1ba7f5189829e63fd536945c8988d61444c19039f16b670"
dependencies = [
"hashbrown 0.12.3",
"hashbrown 0.13.2",
]
[[package]]
name = "lz4_flex"
version = "0.9.5"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a8cbbb2831780bc3b9c15a41f5b49222ef756b6730a95f3decfdd15903eb5a3"
checksum = "8b8c72594ac26bfd34f2d99dfced2edfaddfe8a476e3ff2ca0eb293d925c4f83"
[[package]]
name = "mac"
@ -2631,6 +2603,15 @@ dependencies = [
"libc",
]
[[package]]
name = "memmap2"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d28bba84adfe6646737845bc5ebbfa2c08424eb1c37e94a1fd2a82adb56a872"
dependencies = [
"libc",
]
[[package]]
name = "memoffset"
version = "0.6.5"
@ -2683,7 +2664,7 @@ dependencies = [
"goblin",
"libc",
"mach2",
"memmap2",
"memmap2 0.5.10",
"memoffset 0.6.5",
"minidump-common",
"nix",
@ -2748,12 +2729,9 @@ dependencies = [
[[package]]
name = "murmurhash32"
version = "0.2.0"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d736ff882f0e85fe9689fb23db229616c4c00aee2b3ac282f666d8f20eb25d4a"
dependencies = [
"byteorder",
]
checksum = "d9380db4c04d219ac5c51d14996bbf2c2e9a15229771b53f8671eb6c83cf44df"
[[package]]
name = "native-tls"
@ -3086,9 +3064,9 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
[[package]]
name = "ownedbytes"
version = "0.4.0"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e957eaa64a299f39755416e5b3128c505e9d63a91d0453771ad2ccd3907f8db"
checksum = "c718e498b20704d5fb5d51d07f414a22f61c19254c1708e117b93fd76860739c"
dependencies = [
"stable_deref_trait",
]
@ -3671,7 +3649,7 @@ version = "1.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2eae68fc220f7cf2532e4494aded17545fce192d59cd996e0fe7887f4ceb575"
dependencies = [
"aho-corasick 1.0.2",
"aho-corasick",
"memchr",
"regex-automata 0.3.3",
"regex-syntax 0.7.4",
@ -3692,7 +3670,7 @@ version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39354c10dd07468c2e73926b23bb9c2caca74c5501e38a35da70406f1d923310"
dependencies = [
"aho-corasick 1.0.2",
"aho-corasick",
"memchr",
"regex-syntax 0.7.4",
]
@ -4453,6 +4431,15 @@ version = "0.3.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de"
[[package]]
name = "sketches-ddsketch"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68a406c1882ed7f29cd5e248c9848a80e7cb6ae0fea82346d2746f2f941c07e1"
dependencies = [
"serde",
]
[[package]]
name = "slab"
version = "0.4.8"
@ -4626,14 +4613,14 @@ dependencies = [
[[package]]
name = "tantivy"
version = "0.19.2"
version = "0.20.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5bb26a6b22c84d8be41d99a14016d6f04d30d8d31a2ea411a8ab553af5cc490d"
checksum = "aec540e9cebc88f523f67f596dee213e491f0c55961de013566f267a0c31f5e9"
dependencies = [
"aho-corasick 0.7.20",
"aho-corasick",
"arc-swap",
"async-trait",
"base64 0.13.1",
"base64 0.21.2",
"bitpacking",
"byteorder",
"census",
@ -4642,8 +4629,7 @@ dependencies = [
"downcast-rs",
"fail",
"fastdivide",
"fastfield_codecs",
"fs2",
"fs4",
"htmlescape",
"itertools",
"levenshtein_automata",
@ -4651,24 +4637,26 @@ dependencies = [
"lru",
"lz4_flex",
"measure_time",
"memmap2",
"memmap2 0.6.2",
"murmurhash32",
"num_cpus",
"once_cell",
"oneshot",
"ownedbytes",
"rayon",
"regex",
"rust-stemmers",
"rustc-hash",
"serde",
"serde_json",
"sketches-ddsketch",
"smallvec",
"stable_deref_trait",
"tantivy-bitpacker",
"tantivy-columnar",
"tantivy-common",
"tantivy-fst",
"tantivy-query-grammar",
"tantivy-stacker",
"tantivy-tokenizer-api",
"tempfile",
"thiserror",
"time",
@ -4678,18 +4666,40 @@ dependencies = [
[[package]]
name = "tantivy-bitpacker"
version = "0.3.0"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e71a0c95b82d4292b097a09b989a6380d28c3a86800c841a2d03bae1fc8b9fa6"
checksum = "16099e96f0ede682084469b80d6909dc170aa2b11d2a45538b5b36b2a90090b9"
dependencies = [
"bitpacking",
]
[[package]]
name = "tantivy-columnar"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56e32b024b26eab93eb8648faf08004356bf9d47376557ee4409f4b210163656"
dependencies = [
"fastdivide",
"fnv",
"itertools",
"serde",
"tantivy-bitpacker",
"tantivy-common",
"tantivy-sstable",
"tantivy-stacker",
]
[[package]]
name = "tantivy-common"
version = "0.4.0"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14fef4182bb60df9a4b92cd8ecab39ba2e50a05542934af17eef1f49660705cb"
checksum = "e7d12fdd6ec0f7e0962f129c03c696a85ec567734950cbb2b89af4a293ce342f"
dependencies = [
"async-trait",
"byteorder",
"ownedbytes",
"serde",
"time",
]
[[package]]
@ -4705,15 +4715,45 @@ dependencies = [
[[package]]
name = "tantivy-query-grammar"
version = "0.19.0"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "343e3ada4c1c480953f6960f8a21ce9c76611480ffdd4f4e230fdddce0fc5331"
checksum = "106d8f78ad1da4f0fdd526a0760c326c0573510d4dedabeb1962d35a35879797"
dependencies = [
"combine",
"once_cell",
"regex",
]
[[package]]
name = "tantivy-sstable"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eda34243d3ee64bd8f9ba74a3b0d05f4d07beff7767a727212e9b5a19c13dde7"
dependencies = [
"tantivy-common",
"tantivy-fst",
"zstd 0.12.4",
]
[[package]]
name = "tantivy-stacker"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67b9e9470301b026ad3b95f79a791a2a3ee81f3ab16fbe412a9dd81ff834acf5"
dependencies = [
"murmurhash32",
"tantivy-common",
]
[[package]]
name = "tantivy-tokenizer-api"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64186801b6e06b3a1c4275e23b517835ff4ecbb707318b838dc9de457c062200"
dependencies = [
"serde",
]
[[package]]
name = "tao"
version = "0.16.2"
@ -6181,7 +6221,7 @@ dependencies = [
"pbkdf2",
"sha1",
"time",
"zstd",
"zstd 0.11.2+zstd.1.5.2",
]
[[package]]
@ -6190,7 +6230,16 @@ version = "0.11.2+zstd.1.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4"
dependencies = [
"zstd-safe",
"zstd-safe 5.0.2+zstd.1.5.2",
]
[[package]]
name = "zstd"
version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a27595e173641171fc74a1232b7b1c7a7cb6e18222c11e9dfb9888fa424c53c"
dependencies = [
"zstd-safe 6.0.6",
]
[[package]]
@ -6203,6 +6252,16 @@ dependencies = [
"zstd-sys",
]
[[package]]
name = "zstd-safe"
version = "6.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee98ffd0b48ee95e6c5168188e44a54550b1564d9d530ee21d5f0eaed1069581"
dependencies = [
"libc",
"zstd-sys",
]
[[package]]
name = "zstd-sys"
version = "2.0.8+zstd.1.5.5"

View File

@ -141,6 +141,7 @@ pub struct BaseBranch {
pub current_sha: String,
pub behind: u32,
pub upstream_commits: Vec<VirtualBranchCommit>,
pub recent_commits: Vec<VirtualBranchCommit>,
}
#[derive(Debug, Serialize, Hash, Clone, PartialEq, Eq)]
@ -2211,6 +2212,20 @@ pub fn target_to_base_branch(
let commit = commit_to_vbranch_commit(&commit, None)?;
upstream_commits.push(commit);
}
// get some recent commits
let mut revwalk = repo.revwalk().context("failed to create revwalk")?;
revwalk
.push(target.sha)
.context(format!("failed to push {}", target.sha))?;
let mut recent_commits = vec![];
for oid in revwalk.take(10) {
let oid = oid.context("failed to get oid")?;
let commit = repo.find_commit(oid).context("failed to find commit")?;
let commit = commit_to_vbranch_commit(&commit, None)?;
recent_commits.push(commit);
}
let base = BaseBranch {
branch_name: target.branch_name.clone(),
remote_name: target.remote_name.clone(),
@ -2219,6 +2234,7 @@ pub fn target_to_base_branch(
current_sha: oid.to_string(),
behind: upstream_commits.len() as u32,
upstream_commits,
recent_commits,
};
Ok(base)
}

View File

@ -77,4 +77,5 @@ export class BaseBranch {
currentSha!: string;
behind!: number;
upstreamCommits!: Commit[];
recentCommits!: Commit[];
}

View File

@ -2,6 +2,7 @@
import { slide } from 'svelte/transition';
import { IconTriangleUp, IconTriangleDown } from '$lib/icons';
import type { BaseBranch } from '$lib/vbranches';
import { formatDistanceToNow } from 'date-fns';
export let target: BaseBranch;
@ -9,8 +10,8 @@
let shown = false;
</script>
<div class="flex border-t border-light-400 p-2 dark:border-dark-600">
<div class="ml-4 flex flex-col">
<div class="flex border-t border-light-400 dark:border-dark-600">
<div class="ml-4 flex w-full flex-col">
<div
role="button"
tabindex="0"
@ -23,13 +24,44 @@
{:else}
<IconTriangleUp />
{/if}
<div class="flex flex-row justify-between space-x-2">
<div class="font-bold uppercase">Common base</div>
<div class="flex w-full flex-row justify-between space-x-2">
<div class="flex flex-row space-x-2">
<div class="text-sm font-bold uppercase">Common base</div>
{#if target.behind == 0}
<div class="text-sm">{target.branchName}</div>
{/if}
</div>
{#if !shown}
<div class="pr-4 font-mono text-xs text-light-600">
{target.baseSha.substring(0, 8)}
</div>
{/if}
</div>
</div>
{#if shown}
<div class="h-64 py-2" transition:slide={{ duration: 150 }}>
<div>Hello, my friends, Hello.</div>
<h1 class="mb-2 font-bold">Recent Commits</h1>
<div class="flex w-full flex-col space-y-1 pr-6">
{#each target.recentCommits as commit}
<div class="flex flex-row space-x-1 text-light-700">
<div class="w-24 truncate">{formatDistanceToNow(commit.createdAt)} ago</div>
<div class="flex w-32 flex-row space-x-1 truncate">
<img
class="relative z-30 inline-block h-4 w-4 rounded-full ring-1 ring-white dark:ring-black"
title="Gravatar for {commit.author.email}"
alt="Gravatar for {commit.author.email}"
srcset="{commit.author.gravatarUrl} 2x"
width="100"
height="100"
on:error
/>
<div>{commit.author.name}</div>
</div>
<div class="flex-grow truncate">{commit.description.substring(0, 200)}</div>
<div class="flex-shrink font-mono text-light-600">{commit.id.substring(0, 8)}</div>
</div>
{/each}
</div>
</div>
{/if}
</div>