Skip to content

Commit 5b8c055

Browse files
authored
Merge pull request #10650 from Byron/fix
fix failure when encountering empty stacks
2 parents 31243e9 + efece4f commit 5b8c055

File tree

6 files changed

+20
-14
lines changed

6 files changed

+20
-14
lines changed

.github/workflows/push.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ jobs:
105105
- name: Rust Cache
106106
uses: Swatinem/[email protected]
107107
with:
108-
shared-key: rust-lint
108+
shared-key: lint
109109
save-if: ${{ github.ref == 'refs/heads/master' }}
110110
- run: cargo fmt --check --all
111111
- run: cargo check --workspace --all-targets
@@ -127,7 +127,7 @@ jobs:
127127
- name: Rust Cache
128128
uses: Swatinem/[email protected]
129129
with:
130-
shared-key: rust-but-binary
130+
shared-key: but-binary
131131
save-if: ${{ github.ref == 'refs/heads/master' }}
132132
- run: |
133133
sudo apt update
@@ -149,7 +149,7 @@ jobs:
149149
- name: Rust Cache
150150
uses: Swatinem/[email protected]
151151
with:
152-
shared-key: rust-docs
152+
shared-key: docs
153153
save-if: ${{ github.ref == 'refs/heads/master' }}
154154
- run: cargo doc --no-deps --all-features --document-private-items -p gitbutler-git
155155
env:
@@ -185,7 +185,7 @@ jobs:
185185
- name: Rust Cache
186186
uses: Swatinem/[email protected]
187187
with:
188-
shared-key: rust-testing
188+
shared-key: cargo-test
189189
save-if: ${{ github.ref == 'refs/heads/master' }}
190190
- run: |
191191
cargo test --workspace
@@ -213,7 +213,7 @@ jobs:
213213
- name: Rust Cache
214214
uses: Swatinem/[email protected]
215215
with:
216-
shared-key: rust-testing
216+
shared-key: cargo-test
217217
save-if: ${{ github.ref == 'refs/heads/master' }}
218218
- name: 'cargo check'
219219
run: cargo check --workspace --all-targets --features windows

.github/workflows/test-e2e-playwright.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
- name: Rust Cache
4040
uses: Swatinem/[email protected]
4141
with:
42-
shared-key: rust-but-server-gitbutler-git-but-testing-binary
42+
shared-key: e2e-playwright-rust-binaries
4343
save-if: ${{ github.ref == 'refs/heads/master' }}
4444
- name: Preset Git Configuration and but-testing location
4545
run: |

crates/but-graph/src/ref_metadata_legacy.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ impl RefMetadata for VirtualBranchesTomlMetadata {
323323
}) {
324324
Some(branch) => branch,
325325
None => branches_to_create.pop().context(
326-
"BUG: do not pop off the last branch, remove the whole stack",
326+
"BUG: incoming stack is probably empty, caller should have removed the whole stack",
327327
)?,
328328
};
329329

@@ -560,6 +560,8 @@ impl VirtualBranchesTomlMetadata {
560560
ref_info: managed_ref_info(),
561561
stacks: stacks
562562
.iter()
563+
// We aren't able to handle these well, so let's ignore them.
564+
.filter(|stack| !stack.heads.is_empty())
563565
.sorted_by_key(|s| s.order)
564566
.map(|s| WorkspaceStack {
565567
id: s.id,

crates/but-graph/tests/graph/ref_metadata_legacy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ fn create_workspace_from_scratch_workspace_first() -> anyhow::Result<()> {
10541054
let err = store.set_workspace(&ws).unwrap_err();
10551055
assert_eq!(
10561056
err.to_string(),
1057-
"BUG: do not pop off the last branch, remove the whole stack"
1057+
"BUG: incoming stack is probably empty, caller should have removed the whole stack"
10581058
);
10591059
ws.stacks.pop();
10601060
assert_eq!(ws.stacks.len(), 1);

crates/but-testing/src/args.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use std::path::PathBuf;
66
#[clap(name = "gitbutler-cli", about = "A CLI for GitButler", version = option_env!("GIX_VERSION"))]
77
pub struct Args {
88
/// Enable tracing for debug and performance information printed to stderr.
9-
#[clap(short = 'd', long)]
10-
pub trace: bool,
9+
#[clap(short = 'd', long, action = clap::ArgAction::Count,)]
10+
pub trace: u8,
1111
/// Run as if gitbutler-cli was started in PATH instead of the current working directory.
1212
#[clap(short = 'C', long, default_value = ".", value_name = "PATH")]
1313
pub current_dir: PathBuf,

crates/but-testing/src/main.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ mod command;
1818
async fn main() -> Result<()> {
1919
let args: Args = clap::Parser::parse();
2020

21-
if args.trace {
22-
trace::init()?;
21+
if args.trace > 0 {
22+
trace::init(args.trace)?;
2323
}
2424
let _op_span = tracing::info_span!("cli-op").entered();
2525
static CHANNEL: Option<&str> = option_env!("CHANNEL");
@@ -224,13 +224,17 @@ mod trace {
224224
use tracing_subscriber::layer::SubscriberExt;
225225
use tracing_subscriber::util::SubscriberInitExt;
226226

227-
pub fn init() -> anyhow::Result<()> {
227+
pub fn init(level: u8) -> anyhow::Result<()> {
228228
tracing_subscriber::registry()
229229
.with(
230230
tracing_forest::ForestLayer::from(
231231
tracing_forest::printer::PrettyPrinter::new().writer(std::io::stderr),
232232
)
233-
.with_filter(LevelFilter::DEBUG),
233+
.with_filter(match level {
234+
1 => LevelFilter::INFO,
235+
2 => LevelFilter::DEBUG,
236+
_ => LevelFilter::TRACE,
237+
}),
234238
)
235239
.init();
236240
Ok(())

0 commit comments

Comments
 (0)