Skip to content

Commit 6720e98

Browse files
committed
Use gix::refs::PartialName as even stronger guarantee for what's in there
1 parent 712ce58 commit 6720e98

File tree

7 files changed

+136
-22
lines changed

7 files changed

+136
-22
lines changed

Cargo.lock

Lines changed: 96 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ resolver = "2"
3535
[workspace.dependencies]
3636
bstr = { version = "1.10.0", features = ["serde"] }
3737
# Add the `tracing` or `tracing-detail` features to see more of gitoxide in the logs. Useful to see which programs it invokes.
38-
gix = { git = "https://github.com/Byron/gitoxide", rev = "7dff44754e0fdc369f92221468fb953bad9be60a", default-features = false, features = [] }
38+
gix = { git = "https://github.com/Byron/gitoxide", rev = "7dff44754e0fdc369f92221468fb953bad9be60a", default-features = false, features = ["serde"] }
3939
git2 = { version = "0.18.3", features = [
4040
"vendored-openssl",
4141
"vendored-libgit2",

crates/gitbutler-branch-actions/src/branch.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,12 @@ pub fn list_branches(
3535
for reference in platform.all()?.filter_map(Result::ok) {
3636
// Loosely match on branch names
3737
if let Some(branch_names) = &filter_branch_names {
38-
let has_matching_name = branch_names
39-
.iter()
40-
.any(|branch_name| reference.name().as_bstr().ends_with_str(&branch_name.0));
38+
let has_matching_name = branch_names.iter().any(|branch_name| {
39+
reference
40+
.name()
41+
.as_bstr()
42+
.ends_with_str(branch_name.as_bstr())
43+
});
4144

4245
if !has_matching_name {
4346
continue;
@@ -324,7 +327,7 @@ fn should_list_git_branch(identity: &BranchIdentity) -> bool {
324327
b"gitbutler/oplog",
325328
b"HEAD",
326329
];
327-
!TECHNICAL_IDENTITIES.contains(&identity.0.as_bytes())
330+
!TECHNICAL_IDENTITIES.contains(&identity.as_bytes())
328331
}
329332

330333
/// A filter that can be applied to the branch listing
@@ -413,9 +416,13 @@ pub struct VirtualBranchReference {
413416
/// a list of enriched branch data in the form of `BranchData`.
414417
pub fn get_branch_listing_details(
415418
ctx: &CommandContext,
416-
branch_names: impl IntoIterator<Item = impl Into<BranchIdentity>>,
419+
branch_names: impl IntoIterator<Item = impl TryInto<BranchIdentity>>,
417420
) -> Result<Vec<BranchListingDetails>> {
418-
let branch_names: Vec<_> = branch_names.into_iter().map(Into::into).collect();
421+
let branch_names: Vec<_> = branch_names
422+
.into_iter()
423+
.map(TryInto::try_into)
424+
.filter_map(Result::ok)
425+
.collect();
419426
let repo = ctx.repository();
420427
let branches = list_branches(ctx, None, Some(branch_names.clone()))?;
421428
let default_target = ctx

crates/gitbutler-branch-actions/tests/virtual_branches/list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ mod util {
154154
impl Default for ExpectedBranchListing<'static> {
155155
fn default() -> Self {
156156
ExpectedBranchListing {
157-
identity: "<invalid identity - should always be specified".into(),
157+
identity: "invalid-identity-should-always-be-specified".into(),
158158
remotes: vec![],
159159
virtual_branch_given_name: None,
160160
virtual_branch_in_workspace: false,

crates/gitbutler-branch/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ publish = false
88
[dependencies]
99
anyhow = "1.0.86"
1010
git2.workspace = true
11-
gix.workspace = true
11+
gix = { workspace = true, features = ["serde"] }
1212
gitbutler-reference.workspace = true
1313
gitbutler-serde.workspace = true
1414
gitbutler-id.workspace = true

0 commit comments

Comments
 (0)