mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-11-22 19:14:31 +03:00
Move RepoActionsExt out of gitbutler-repository
This is a higher level trait with lots of dependencies
This commit is contained in:
parent
9c92eb6107
commit
4ef288f60d
25
Cargo.lock
generated
25
Cargo.lock
generated
@ -2189,6 +2189,7 @@ dependencies = [
|
||||
"gitbutler-project",
|
||||
"gitbutler-reference",
|
||||
"gitbutler-repo",
|
||||
"gitbutler-repo-actions",
|
||||
"gitbutler-serde",
|
||||
"gitbutler-stack",
|
||||
"gitbutler-stack-api",
|
||||
@ -2541,6 +2542,28 @@ dependencies = [
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gitbutler-repo-actions"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"git2",
|
||||
"gitbutler-command-context",
|
||||
"gitbutler-commit",
|
||||
"gitbutler-error",
|
||||
"gitbutler-git",
|
||||
"gitbutler-id",
|
||||
"gitbutler-project",
|
||||
"gitbutler-reference",
|
||||
"gitbutler-repo",
|
||||
"gitbutler-stack",
|
||||
"gitbutler-time",
|
||||
"log",
|
||||
"serde",
|
||||
"tokio",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gitbutler-secret"
|
||||
version = "0.0.0"
|
||||
@ -2595,6 +2618,7 @@ dependencies = [
|
||||
"gitbutler-patch-reference",
|
||||
"gitbutler-reference",
|
||||
"gitbutler-repo",
|
||||
"gitbutler-repo-actions",
|
||||
"gitbutler-stack",
|
||||
"gitbutler-testsupport",
|
||||
"gitbutler-time",
|
||||
@ -2668,6 +2692,7 @@ dependencies = [
|
||||
"gitbutler-project",
|
||||
"gitbutler-reference",
|
||||
"gitbutler-repo",
|
||||
"gitbutler-repo-actions",
|
||||
"gitbutler-secret",
|
||||
"gitbutler-stack",
|
||||
"gitbutler-storage",
|
||||
|
@ -10,6 +10,7 @@ members = [
|
||||
"crates/gitbutler-sync",
|
||||
"crates/gitbutler-oplog",
|
||||
"crates/gitbutler-repo",
|
||||
"crates/gitbutler-repo-actions",
|
||||
"crates/gitbutler-command-context",
|
||||
"crates/gitbutler-feedback",
|
||||
"crates/gitbutler-config",
|
||||
@ -68,6 +69,7 @@ gitbutler-branch-actions = { path = "crates/gitbutler-branch-actions" }
|
||||
gitbutler-sync = { path = "crates/gitbutler-sync" }
|
||||
gitbutler-oplog = { path = "crates/gitbutler-oplog" }
|
||||
gitbutler-repo = { path = "crates/gitbutler-repo" }
|
||||
gitbutler-repo-actions = { path = "crates/gitbutler-repo-actions" }
|
||||
gitbutler-command-context = { path = "crates/gitbutler-command-context" }
|
||||
gitbutler-feedback = { path = "crates/gitbutler-feedback" }
|
||||
gitbutler-config = { path = "crates/gitbutler-config" }
|
||||
|
@ -13,6 +13,7 @@ gix = { workspace = true, features = ["blob-diff", "revision"] }
|
||||
tokio.workspace = true
|
||||
gitbutler-oplog.workspace = true
|
||||
gitbutler-repo.workspace = true
|
||||
gitbutler-repo-actions.workspace = true
|
||||
gitbutler-user.workspace = true
|
||||
gitbutler-branch.workspace = true
|
||||
gitbutler-reference.workspace = true
|
||||
|
@ -26,7 +26,8 @@ use gitbutler_oplog::{
|
||||
};
|
||||
use gitbutler_project::{FetchResult, Project};
|
||||
use gitbutler_reference::{ReferenceName, Refname, RemoteRefname};
|
||||
use gitbutler_repo::{RepoActionsExt, RepositoryExt};
|
||||
use gitbutler_repo::RepositoryExt;
|
||||
use gitbutler_repo_actions::RepoActionsExt;
|
||||
use gitbutler_stack::{BranchOwnershipClaims, StackId};
|
||||
use std::path::PathBuf;
|
||||
use tracing::instrument;
|
||||
|
@ -6,7 +6,8 @@ use gitbutler_command_context::CommandContext;
|
||||
use gitbutler_error::error::Marker;
|
||||
use gitbutler_project::FetchResult;
|
||||
use gitbutler_reference::{Refname, RemoteRefname};
|
||||
use gitbutler_repo::{LogUntil, RepoActionsExt, RepositoryExt};
|
||||
use gitbutler_repo::{LogUntil, RepositoryExt};
|
||||
use gitbutler_repo_actions::RepoActionsExt;
|
||||
use gitbutler_stack::{BranchOwnershipClaims, Stack, Target, VirtualBranchesHandle};
|
||||
use gitbutler_stack_api::StackExt;
|
||||
use serde::Serialize;
|
||||
|
@ -10,8 +10,9 @@ use gitbutler_project::access::WorktreeWritePermission;
|
||||
use gitbutler_reference::{Refname, RemoteRefname};
|
||||
use gitbutler_repo::{
|
||||
rebase::{cherry_rebase_group, gitbutler_merge_commits},
|
||||
LogUntil, RepoActionsExt, RepositoryExt,
|
||||
LogUntil, RepositoryExt,
|
||||
};
|
||||
use gitbutler_repo_actions::RepoActionsExt;
|
||||
use gitbutler_stack::{BranchOwnershipClaims, Stack, StackId};
|
||||
use gitbutler_stack_api::StackExt;
|
||||
use gitbutler_time::time::now_since_unix_epoch_ms;
|
||||
|
@ -7,7 +7,8 @@ use gitbutler_commit::commit_headers::CommitHeadersV2;
|
||||
use gitbutler_oplog::SnapshotExt;
|
||||
use gitbutler_project::access::WorktreeWritePermission;
|
||||
use gitbutler_reference::{normalize_branch_name, ReferenceName, Refname};
|
||||
use gitbutler_repo::{RepoActionsExt, RepositoryExt};
|
||||
use gitbutler_repo::RepositoryExt;
|
||||
use gitbutler_repo_actions::RepoActionsExt;
|
||||
use gitbutler_stack::{Stack, StackId};
|
||||
use tracing::instrument;
|
||||
|
||||
|
@ -6,7 +6,8 @@ use gitbutler_branch::ReferenceExt;
|
||||
use gitbutler_command_context::CommandContext;
|
||||
use gitbutler_commit::commit_ext::CommitExt;
|
||||
use gitbutler_reference::{Refname, RemoteRefname};
|
||||
use gitbutler_repo::{LogUntil, RepoActionsExt, RepositoryExt};
|
||||
use gitbutler_repo::{LogUntil, RepositoryExt};
|
||||
use gitbutler_repo_actions::RepoActionsExt;
|
||||
use gitbutler_serde::BStringForFrontend;
|
||||
use gitbutler_stack::{Target, VirtualBranchesHandle};
|
||||
use serde::Serialize;
|
||||
|
@ -6,7 +6,7 @@ use gitbutler_command_context::CommandContext;
|
||||
use gitbutler_commit::commit_ext::CommitExt;
|
||||
use gitbutler_patch_reference::{CommitOrChangeId, PatchReference};
|
||||
use gitbutler_project::Project;
|
||||
use gitbutler_repo::RepoActionsExt;
|
||||
use gitbutler_repo_actions::RepoActionsExt;
|
||||
use gitbutler_stack::{Stack, StackId, Target};
|
||||
use gitbutler_stack_api::{
|
||||
commit_by_oid_or_change_id, CommitsForId, PatchReferenceUpdate, StackExt,
|
||||
|
@ -4,8 +4,9 @@ use gitbutler_command_context::CommandContext;
|
||||
use gitbutler_project::access::WorktreeWritePermission;
|
||||
use gitbutler_repo::{
|
||||
rebase::{cherry_rebase_group, gitbutler_merge_commits},
|
||||
LogUntil, RepoActionsExt as _, RepositoryExt as _,
|
||||
LogUntil, RepositoryExt as _,
|
||||
};
|
||||
use gitbutler_repo_actions::RepoActionsExt as _;
|
||||
use gitbutler_stack::{Stack, StackId, Target, VirtualBranchesHandle};
|
||||
use gitbutler_stack_api::StackExt;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -25,8 +25,9 @@ use gitbutler_project::access::WorktreeWritePermission;
|
||||
use gitbutler_reference::{normalize_branch_name, Refname, RemoteRefname};
|
||||
use gitbutler_repo::{
|
||||
rebase::{cherry_rebase, cherry_rebase_group},
|
||||
LogUntil, RepoActionsExt, RepositoryExt,
|
||||
LogUntil, RepositoryExt,
|
||||
};
|
||||
use gitbutler_repo_actions::RepoActionsExt;
|
||||
use gitbutler_stack::{
|
||||
reconcile_claims, BranchOwnershipClaims, Stack, StackId, Target, VirtualBranchesHandle,
|
||||
};
|
||||
|
29
crates/gitbutler-repo-actions/Cargo.toml
Normal file
29
crates/gitbutler-repo-actions/Cargo.toml
Normal file
@ -0,0 +1,29 @@
|
||||
[package]
|
||||
name = "gitbutler-repo-actions"
|
||||
version = "0.0.0"
|
||||
edition = "2021"
|
||||
authors = ["GitButler <gitbutler@gitbutler.com>"]
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
git2.workspace = true
|
||||
serde = { workspace = true, features = ["std"] }
|
||||
tokio = { workspace = true, features = [
|
||||
"rt-multi-thread",
|
||||
"rt",
|
||||
"macros",
|
||||
"sync",
|
||||
] }
|
||||
log = "^0.4"
|
||||
anyhow = "1.0.86"
|
||||
gitbutler-command-context.workspace = true
|
||||
tracing.workspace = true
|
||||
gitbutler-stack.workspace = true
|
||||
gitbutler-id.workspace = true
|
||||
gitbutler-git.workspace = true
|
||||
gitbutler-project.workspace = true
|
||||
gitbutler-error.workspace = true
|
||||
gitbutler-commit.workspace = true
|
||||
gitbutler-reference.workspace = true
|
||||
gitbutler-repo.workspace = true
|
||||
gitbutler-time.workspace = true
|
4
crates/gitbutler-repo-actions/src/lib.rs
Normal file
4
crates/gitbutler-repo-actions/src/lib.rs
Normal file
@ -0,0 +1,4 @@
|
||||
pub mod askpass;
|
||||
|
||||
mod repository;
|
||||
pub use repository::RepoActionsExt;
|
@ -8,7 +8,8 @@ use gitbutler_project::AuthKey;
|
||||
use gitbutler_reference::{Refname, RemoteRefname};
|
||||
use gitbutler_stack::{Stack, StackId};
|
||||
|
||||
use crate::{askpass, credentials, RepositoryExt};
|
||||
use crate::askpass;
|
||||
use gitbutler_repo::{credentials, LogUntil, RepositoryExt};
|
||||
pub trait RepoActionsExt {
|
||||
fn fetch(&self, remote_name: &str, askpass: Option<String>) -> Result<()>;
|
||||
fn push(
|
||||
@ -317,22 +318,6 @@ impl RepoActionsExt for CommandContext {
|
||||
}
|
||||
}
|
||||
|
||||
type OidFilter = dyn Fn(&git2::Commit) -> Result<bool>;
|
||||
|
||||
/// Generally, all traversals will use no particular ordering, it's implementation defined in `git2`.
|
||||
pub enum LogUntil {
|
||||
/// Traverse until one sees (or gets commits older than) the given commit.
|
||||
/// Do not return that commit or anything older than that.
|
||||
Commit(git2::Oid),
|
||||
/// Traverse the given `n` commits.
|
||||
Take(usize),
|
||||
/// Traverse all commits until the given condition returns `false` for a commit.
|
||||
/// Note that this commit-id will also be returned.
|
||||
When(Box<OidFilter>),
|
||||
/// Traverse the whole graph until it is exhausted.
|
||||
End,
|
||||
}
|
||||
|
||||
async fn handle_git_prompt_push(
|
||||
prompt: String,
|
||||
askpass: Option<Option<StackId>>,
|
@ -1,13 +1,10 @@
|
||||
pub mod rebase;
|
||||
|
||||
mod repository;
|
||||
pub use repository::{LogUntil, RepoActionsExt};
|
||||
|
||||
mod commands;
|
||||
pub use commands::{FileInfo, RepoCommands};
|
||||
|
||||
mod repository_ext;
|
||||
pub use repository_ext::{GixRepositoryExt, RepositoryExt};
|
||||
pub use repository_ext::{GixRepositoryExt, LogUntil, RepositoryExt};
|
||||
|
||||
pub mod credentials;
|
||||
|
||||
@ -15,6 +12,4 @@ mod config;
|
||||
|
||||
pub use config::Config;
|
||||
|
||||
pub mod askpass;
|
||||
|
||||
pub mod temporary_workdir;
|
||||
|
@ -4,7 +4,7 @@ use std::os::unix::fs::PermissionsExt;
|
||||
use std::os::windows::process::CommandExt;
|
||||
use std::{io::Write, path::Path, process::Stdio, str};
|
||||
|
||||
use crate::{Config, LogUntil};
|
||||
use crate::Config;
|
||||
use anyhow::{anyhow, bail, Context, Result};
|
||||
use bstr::BString;
|
||||
use git2::{BlameOptions, StatusOptions, Tree};
|
||||
@ -704,3 +704,19 @@ impl GixRepositoryExt for gix::Repository {
|
||||
Ok(self)
|
||||
}
|
||||
}
|
||||
|
||||
type OidFilter = dyn Fn(&git2::Commit) -> Result<bool>;
|
||||
|
||||
/// Generally, all traversals will use no particular ordering, it's implementation defined in `git2`.
|
||||
pub enum LogUntil {
|
||||
/// Traverse until one sees (or gets commits older than) the given commit.
|
||||
/// Do not return that commit or anything older than that.
|
||||
Commit(git2::Oid),
|
||||
/// Traverse the given `n` commits.
|
||||
Take(usize),
|
||||
/// Traverse all commits until the given condition returns `false` for a commit.
|
||||
/// Note that this commit-id will also be returned.
|
||||
When(Box<OidFilter>),
|
||||
/// Traverse the whole graph until it is exhausted.
|
||||
End,
|
||||
}
|
||||
|
@ -30,4 +30,5 @@ path = "tests/mod.rs"
|
||||
[dev-dependencies]
|
||||
gitbutler-git = { workspace = true, features = ["test-askpass-path"] }
|
||||
gitbutler-testsupport.workspace = true
|
||||
gitbutler-repo-actions.workspace = true
|
||||
tempfile = "3.13"
|
||||
|
@ -3,7 +3,8 @@ use gitbutler_command_context::CommandContext;
|
||||
use gitbutler_commit::commit_ext::CommitExt;
|
||||
use gitbutler_patch_reference::{CommitOrChangeId, PatchReference};
|
||||
use gitbutler_reference::RemoteRefname;
|
||||
use gitbutler_repo::{LogUntil, RepoActionsExt, RepositoryExt as _};
|
||||
use gitbutler_repo::{LogUntil, RepositoryExt as _};
|
||||
use gitbutler_repo_actions::RepoActionsExt;
|
||||
use gitbutler_stack::VirtualBranchesHandle;
|
||||
use gitbutler_stack_api::{PatchReferenceUpdate, StackExt, TargetUpdate};
|
||||
use itertools::Itertools;
|
||||
|
@ -55,6 +55,7 @@ gitbutler-watcher.workspace = true
|
||||
gitbutler-branch-actions.workspace = true
|
||||
gitbutler-oplog.workspace = true
|
||||
gitbutler-repo.workspace = true
|
||||
gitbutler-repo-actions.workspace = true
|
||||
gitbutler-command-context.workspace = true
|
||||
gitbutler-feedback.workspace = true
|
||||
gitbutler-fs.workspace = true
|
||||
|
@ -6,7 +6,8 @@ use gitbutler_command_context::CommandContext;
|
||||
use gitbutler_project as projects;
|
||||
use gitbutler_project::ProjectId;
|
||||
use gitbutler_reference::RemoteRefname;
|
||||
use gitbutler_repo::{RepoActionsExt, RepositoryExt};
|
||||
use gitbutler_repo::RepositoryExt;
|
||||
use gitbutler_repo_actions::RepoActionsExt;
|
||||
use gitbutler_stack::StackId;
|
||||
|
||||
#[derive(Clone)]
|
||||
|
@ -1,6 +1,6 @@
|
||||
pub mod commands {
|
||||
use gitbutler_id::id::Id;
|
||||
use gitbutler_repo::askpass::{self, AskpassRequest};
|
||||
use gitbutler_repo_actions::askpass::{self, AskpassRequest};
|
||||
|
||||
#[tauri::command(async)]
|
||||
#[tracing::instrument(skip(response))]
|
||||
|
@ -77,7 +77,7 @@ fn main() {
|
||||
// SAFETY(qix-): This is safe because we're initializing the askpass broker here,
|
||||
// SAFETY(qix-): before any other threads would ever access it.
|
||||
unsafe {
|
||||
gitbutler_repo::askpass::init({
|
||||
gitbutler_repo_actions::askpass::init({
|
||||
let handle = app_handle.clone();
|
||||
move |event| {
|
||||
handle
|
||||
|
Loading…
Reference in New Issue
Block a user