Skip to content

Commit

Permalink
refactor gitbutler-git to be cli-only and allow prompt handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
Qix- committed Mar 19, 2024
1 parent 2670fb4 commit bd288f9
Show file tree
Hide file tree
Showing 24 changed files with 465 additions and 2,038 deletions.
31 changes: 30 additions & 1 deletion .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
rust: ${{ steps.filter.outputs.rust }}
gitbutler-app: ${{ steps.filter.outputs.gitbutler-app }}
gitbutler-changeset: ${{ steps.filter.outputs.gitbutler-changeset }}
gitbutler-git: ${{ steps.filter.outputs.gitbutler-git }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
Expand All @@ -36,6 +37,9 @@ jobs:
gitbutler-changeset:
- *rust
- 'gitbutler-changeset/**'
gitbutler-git:
- *rust
- 'gitbutler-git/**'
lint-node:
needs: changes
Expand Down Expand Up @@ -87,7 +91,7 @@ jobs:
- uses: ./.github/actions/init-env-rust
# TODO(qix-): we have to exclude the app here for now because for some
# TODO(qix-): reason it doesn't build with the docs feature enabled.
- run: cargo doc --no-deps --all-features --document-private-items -p gitbutler-changeset
- run: cargo doc --no-deps --all-features --document-private-items -p gitbutler-changeset -p gitbutler-git
env:
RUSTDOCFLAGS: -Dwarnings

Expand Down Expand Up @@ -139,12 +143,37 @@ jobs:
features: ${{ toJson(matrix.features) }}
action: ${{ matrix.action }}

check-gitbutler-git:
needs: [changes, rust-init]
if: ${{ needs.changes.outputs.gitbutler-git == 'true' }}
runs-on: ubuntu-latest
container:
image: ghcr.io/gitbutlerapp/ci-base-image:latest
strategy:
matrix:
action:
- test
- check
features:
- ''
- '*'
- []
- [tokio]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/check-crate
with:
crate: gitbutler-git
features: ${{ toJson(matrix.features) }}
action: ${{ matrix.action }}

check-rust:
if: always()
needs:
- changes
- check-gitbutler-app
- check-gitbutler-changeset
- check-gitbutler-git
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
Expand Down
74 changes: 71 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
members = [
"gitbutler-app",
"gitbutler-changeset",
"gitbutler-git",
]
resolver = "2"

Expand Down
27 changes: 7 additions & 20 deletions gitbutler-git/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,24 @@ path = "src/lib.rs"

[[bin]]
name = "gitbutler-git-askpass"
path = "src/backend/cli/bin/askpass.rs"
required-features = ["cli"]
path = "src/cli/bin/askpass.rs"

[[bin]]
name = "gitbutler-git-setsid"
path = "src/backend/cli/bin/setsid.rs"
required-features = ["cli"]
path = "src/cli/bin/setsid.rs"

[features]
default = ["git2", "cli", "serde", "tokio"]
cli = ["dep:nix", "dep:rand", "dep:futures", "dep:sysinfo"]
git2 = ["dep:git2", "dep:dirs"]
default = ["serde", "tokio"]
serde = ["dep:serde"]
tokio = ["dep:tokio"]

[dependencies]
thiserror.workspace = true
git2 = { workspace = true, optional = true }
serde = { workspace = true, optional = true }
tokio = { workspace = true, optional = true, features = ["process", "rt", "process", "time", "io-util", "net", "fs", "sync"]}
rand = { version = "0.8.5", optional = true }
futures = { version = "0.3.30", optional = true }
sysinfo = { version = "0.30.5", optional = true }
dirs = { version = "5.0.1", optional = true }

[dev-dependencies]
git2.workspace = true # Used for tests
async-trait = "0.1.77"
russh = { version = "0.41.0-beta.4", features = ["openssl"] }
russh-keys = "0.41.0-beta.3"
tokio = { workspace = true, features = ["rt-multi-thread"] }
rand = "0.8.5"
futures = "0.3.30"
sysinfo = "0.30.5"

[target."cfg(unix)".dependencies]
nix = { version = "0.27.1", optional = true, features = ["process", "socket", "user"] }
nix = { version = "0.27.1", features = ["process", "socket", "user"] }
4 changes: 0 additions & 4 deletions gitbutler-git/src/backend.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
#[cfg(feature = "cli")]
pub mod cli;

// We use the libgit2 backend for tests as well.
#[cfg(any(test, feature = "git2"))]
pub mod git2;
37 changes: 0 additions & 37 deletions gitbutler-git/src/backend/cli.rs

This file was deleted.

Loading

0 comments on commit bd288f9

Please sign in to comment.