Skip to content

Commit 86ed7c9

Browse files
authored
Merge pull request #9605 from Byron/next
V3 for branch creation
2 parents c024568 + a849165 commit 86ed7c9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2930
-620
lines changed

Cargo.lock

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

crates/but-api/Cargo.toml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,10 @@ publish = false
1313

1414
[dependencies]
1515
serde.workspace = true
16-
futures-util = { version = "0.3", default-features = false, features = [
17-
"sink",
18-
"std",
19-
] }
2016
tokio = { workspace = true, features = ["full"] }
21-
tokio-util = "0.7.15"
22-
dirs.workspace = true
23-
bstr.workspace = true
2417
anyhow.workspace = true
2518
serde_json = "1.0.140"
2619
tracing.workspace = true
27-
tracing-subscriber = { version = "0.3", features = [
28-
"env-filter",
29-
"std",
30-
"fmt",
31-
] }
3220

3321
but-settings.workspace = true
3422
gitbutler-user.workspace = true
@@ -59,10 +47,7 @@ gix = { workspace = true, features = [
5947
git2.workspace = true
6048
gitbutler-feedback.workspace = true
6149
gitbutler-error.workspace = true
62-
gitbutler-diff.workspace = true
63-
gitbutler-watcher.workspace = true
6450
but-rules.workspace = true
65-
but-action.workspace = true
6651
reqwest = { version = "0.12", features = ["json"] }
6752
gitbutler-forge.workspace = true
6853
open = "5.3"

crates/but-core/src/ref_metadata.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,22 @@ impl Workspace {
5858
.iter()
5959
.find_map(|stack| stack.branches.iter().find(|b| b.ref_name.as_ref() == name))
6060
}
61+
62+
/// Find the `(stack_idx, branch_idx)` of `name` within our stack branches and return it,
63+
/// for direct access like `ws.stacks[stack_idx].branches[branch_idx]`.
64+
pub fn find_owner_indexes_by_name(
65+
&self,
66+
name: &gix::refs::FullNameRef,
67+
) -> Option<(usize, usize)> {
68+
self.stacks
69+
.iter()
70+
.enumerate()
71+
.find_map(|(stack_idx, stack)| {
72+
stack.branches.iter().enumerate().find_map(|(seg_idx, b)| {
73+
(b.ref_name.as_ref() == name).then_some((stack_idx, seg_idx))
74+
})
75+
})
76+
}
6177
}
6278

6379
/// Metadata about branches, associated with any Git branch.
@@ -120,6 +136,18 @@ pub struct RefInfo {
120136
pub updated_at: Option<gix::date::Time>,
121137
}
122138

139+
/// Mutations
140+
impl RefInfo {
141+
/// Set the `updated_at` field to the current time.
142+
pub fn set_updated_to_now(&mut self) {
143+
self.updated_at = Some(gix::date::Time::now_local_or_utc());
144+
}
145+
/// Set the `created_at` field to the current time.
146+
pub fn set_created_to_now(&mut self) {
147+
self.created_at = Some(gix::date::Time::now_local_or_utc());
148+
}
149+
}
150+
123151
impl std::fmt::Debug for RefInfo {
124152
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
125153
let format = gix::date::time::format::ISO8601;

crates/but-graph/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,4 @@ gix-testtools.workspace = true
3434
insta = "1.43.1"
3535
termtree = "0.5.1"
3636
but-testsupport.workspace = true
37-
regex = "1.11.1"
3837

crates/but-graph/src/api.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,19 @@ impl Graph {
8585
})
8686
}
8787

88+
/// Return the segment that is named `name`,
89+
///
90+
/// Note that tags may or may not be included in the graph, depending on how it was created.
91+
///
92+
/// ### Performance
93+
///
94+
/// This is a brute-force search through all nodes and all data in the graph - beware of hot-loop usage.
95+
pub fn named_segment_by_ref_name(&self, name: &gix::refs::FullNameRef) -> Option<&Segment> {
96+
self.inner
97+
.node_weights()
98+
.find(|s| s.ref_name.as_ref().is_some_and(|rn| rn.as_ref() == name))
99+
}
100+
88101
/// Starting a `segment`, ignore all segments that have no commit and return the first commit
89102
/// of a non-empty segment.
90103
///

0 commit comments

Comments
 (0)