-
Notifications
You must be signed in to change notification settings - Fork 558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
V3 Uncommitted Files, CLI and Filewatching #5912
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[package] | ||
name = "but-cli" | ||
version = "0.0.0" | ||
edition = "2021" | ||
authors = ["GitButler <[email protected]>"] | ||
publish = false | ||
rust-version = "1.74" | ||
|
||
[[bin]] | ||
name = "but-cli" | ||
path = "src/main.rs" | ||
doctest = false | ||
|
||
[dependencies] | ||
but-core.workspace = true | ||
|
||
clap = { version = "4.5.23", features = ["derive", "env"] } | ||
anyhow = "1.0.95" | ||
tracing-forest = { version = "0.1.6" } | ||
tracing-subscriber.workspace = true | ||
tracing.workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use std::path::PathBuf; | ||
|
||
#[derive(Debug, clap::Parser)] | ||
#[clap(name = "gitbutler-cli", about = "A CLI for GitButler", version = option_env!("GIX_VERSION"))] | ||
pub struct Args { | ||
/// Enable tracing for debug and performance information printed to stderr. | ||
#[clap(short = 'd', long)] | ||
pub trace: bool, | ||
/// Run as if gitbutler-cli was started in PATH instead of the current working directory. | ||
#[clap(short = 'C', long, default_value = ".", value_name = "PATH")] | ||
pub current_dir: PathBuf, | ||
|
||
#[clap(subcommand)] | ||
pub cmd: Subcommands, | ||
} | ||
|
||
#[derive(Debug, clap::Subcommand)] | ||
pub enum Subcommands { | ||
/// Update the local workspace against an updated remote or target branch. | ||
Status, | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn clap() { | ||
use clap::CommandFactory; | ||
Args::command().debug_assert(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
fn debug_print(this: impl std::fmt::Debug) -> anyhow::Result<()> { | ||
println!("{:#?}", this); | ||
Ok(()) | ||
} | ||
|
||
pub mod status { | ||
use crate::command::debug_print; | ||
|
||
pub fn doit() -> anyhow::Result<()> { | ||
debug_print("call into but-core") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//! A debug-CLI for making `but`-crates functionality available in real-world repositories. | ||
use anyhow::Result; | ||
|
||
mod args; | ||
use args::Args; | ||
|
||
mod command; | ||
|
||
fn main() -> Result<()> { | ||
let args: Args = clap::Parser::parse(); | ||
|
||
if args.trace { | ||
trace::init()?; | ||
} | ||
let _op_span = tracing::info_span!("cli-op").entered(); | ||
|
||
match args.cmd { | ||
args::Subcommands::Status => command::status::doit(), | ||
} | ||
} | ||
|
||
mod trace { | ||
use tracing::metadata::LevelFilter; | ||
use tracing_subscriber::layer::SubscriberExt; | ||
use tracing_subscriber::util::SubscriberInitExt; | ||
use tracing_subscriber::Layer; | ||
|
||
pub fn init() -> anyhow::Result<()> { | ||
tracing_subscriber::registry() | ||
.with( | ||
tracing_forest::ForestLayer::from( | ||
tracing_forest::printer::PrettyPrinter::new().writer(std::io::stderr), | ||
) | ||
.with_filter(LevelFilter::DEBUG), | ||
) | ||
.init(); | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[package] | ||
name = "but-core" | ||
version = "0.0.0" | ||
edition = "2021" | ||
authors = ["GitButler <[email protected]>"] | ||
publish = false | ||
|
||
[lib] | ||
doctest = false | ||
|
||
[dependencies] | ||
serde = { workspace = true, features = ["std"] } | ||
bstr.workspace = true | ||
anyhow = "1.0.95" | ||
gix = { workspace = true, features = ["dirwalk", "credentials", "parallel"] } | ||
walkdir = "2.5.0" | ||
toml.workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#![deny(missing_docs, rust_2018_idioms)] | ||
//! The basic primitives that GitButler is built around. | ||
//! | ||
//! It also is a catch-all for code until it's worth putting it into its own crate. | ||
//! | ||
//! ### House-~~Rules~~ Guidance | ||
//! | ||
//! * Try hard to do write all the 'right' tests | ||
//! - Tests should challenge the implementation, try hard to break it. | ||
//! - capture *all* business requirements | ||
//! - Try to avoid doing read-only filesystem fixtures with `tempdir`, instead use `gitbutler-testtools::readonly`. | ||
//! * minimal dependencies | ||
//! - both for the crate and for parameters of functions as well. | ||
//! - i.e. try to avoid 'God' structures so the function only has access to what it needs to. | ||
//! * The filesystem is `Sync` but we don't have atomic operations | ||
//! - Let's be very careful about changes to the filesystem, must at least be on the level of Git which means `.lock` files instead of direct writes. | ||
//! - If only one part of the application is supposed to change the worktree, let's protect the Application from itself by using `gitbutler::access` just like we do now. | ||
//! * Make it work, make it work right, and if time and profiler permits, make it work fast. | ||
//! * All of the above can and should be scrutinized and is there is no hard rules. | ||
|
||
/// Functions related to a Git worktree, i.e. the files checked out from a repository. | ||
pub mod worktree { | ||
use std::path::Path; | ||
|
||
/// Return a list of items that live underneath `worktree_root` that changed and thus can become part of a commit. | ||
pub fn committable_entries(_worktree_root: &Path) -> anyhow::Result<()> { | ||
todo!() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#[test] | ||
fn itworks() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -679,7 +679,6 @@ pub fn diff_files_into_hunks( | |
} | ||
|
||
#[cfg(test)] | ||
|
||
mod test { | ||
use super::*; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh my days! This is so much better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did it to highlight the two-class society we are building :D.