File tree Expand file tree Collapse file tree 7 files changed +83
-1
lines changed
gitoxide-core/src/repository Expand file tree Collapse file tree 7 files changed +83
-1
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,8 @@ Please see _'Development Status'_ for a listing of all crates and their capabili
4848 * ** mailmap**
4949 * [x] ** verify** - check entries of a mailmap file for parse errors and display them
5050 * ** repository**
51+ * ** exclude**
52+ * [x] ** query** - check if path specs are excluded via gits exclusion rules like ` .gitignore ` .
5153 * ** verify** - validate a whole repository, for now only the object database.
5254 * ** commit**
5355 * [x] ** describe** - identify a commit by its closest tag in its past
Original file line number Diff line number Diff line change @@ -436,7 +436,8 @@ See its [README.md](https://github.com/Byron/gitoxide/blob/main/git-lock/README.
436436 * ** refs**
437437 * [ ] run transaction hooks and handle special repository states like quarantine
438438 * [ ] support for different backends like ` files ` and ` reftable `
439- * [ ] worktrees
439+ * ** worktrees**
440+ * [ ] open a repository with worktrees
440441 * [ ] remotes with push and pull
441442 * [x] mailmap
442443 * [x] object replacements (` git replace ` )
Original file line number Diff line number Diff line change 4040//! Callers may `.expect()` on the result to indicate they don't wish to handle this special and rare case. Note that servers should not
4141//! ever get into a code-path which does panic though.
4242
43+ /// A dummy type to represent path specs and help finding all spots that take path specs once it is implemented.
44+ #[ derive( Clone , Debug ) ]
45+ pub struct Spec ( String ) ;
46+
47+ impl FromStr for Spec {
48+ type Err = std:: convert:: Infallible ;
49+
50+ fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
51+ Ok ( Spec ( s. to_owned ( ) ) )
52+ }
53+ }
54+
4355mod convert;
56+
4457pub use convert:: * ;
58+ use std:: str:: FromStr ;
Original file line number Diff line number Diff line change 1+ use anyhow:: bail;
2+ use std:: io;
3+ use std:: path:: PathBuf ;
4+
5+ use crate :: OutputFormat ;
6+ use git_repository as git;
7+
8+ pub mod query {
9+ use crate :: OutputFormat ;
10+ use git_repository as git;
11+
12+ pub struct Options {
13+ pub format : OutputFormat ,
14+ pub pathspecs : Vec < git:: path:: Spec > ,
15+ }
16+ }
17+
18+ pub fn query (
19+ repository : PathBuf ,
20+ mut out : impl io:: Write ,
21+ query:: Options { format, pathspecs } : query:: Options ,
22+ ) -> anyhow:: Result < ( ) > {
23+ if format != OutputFormat :: Human {
24+ bail ! ( "JSON output isn't implemented yet" ) ;
25+ }
26+
27+ let repo = git:: open ( repository) ?. apply_environment ( ) ;
28+ todo ! ( "impl" ) ;
29+ }
Original file line number Diff line number Diff line change @@ -16,3 +16,5 @@ pub mod verify;
1616pub mod odb;
1717
1818pub mod mailmap;
19+
20+ pub mod exclude;
Original file line number Diff line number Diff line change @@ -191,6 +191,22 @@ pub fn main() -> Result<()> {
191191 } ,
192192 ) ,
193193 } ,
194+ repo:: Subcommands :: Exclude { cmd } => match cmd {
195+ repo:: exclude:: Subcommands :: Query { pathspecs } => prepare_and_run (
196+ "repository-exclude-query" ,
197+ verbose,
198+ progress,
199+ progress_keep_open,
200+ None ,
201+ move |_progress, out, _err| {
202+ core:: repository:: exclude:: query (
203+ repository,
204+ out,
205+ core:: repository:: exclude:: query:: Options { format, pathspecs } ,
206+ )
207+ } ,
208+ ) ,
209+ } ,
194210 repo:: Subcommands :: Mailmap { cmd } => match cmd {
195211 repo:: mailmap:: Subcommands :: Entries => prepare_and_run (
196212 "repository-mailmap-entries" ,
Original file line number Diff line number Diff line change @@ -370,6 +370,24 @@ pub mod repo {
370370 #[ clap( subcommand) ]
371371 cmd : mailmap:: Subcommands ,
372372 } ,
373+ /// Interact with the exclude files like .gitignore.
374+ Exclude {
375+ #[ clap( subcommand) ]
376+ cmd : exclude:: Subcommands ,
377+ } ,
378+ }
379+
380+ pub mod exclude {
381+ use git_repository as git;
382+
383+ #[ derive( Debug , clap:: Subcommand ) ]
384+ pub enum Subcommands {
385+ /// Check if path-specs are excluded and print the result similar to `git check-ignore`.
386+ Query {
387+ /// The git path specifications to check for exclusion.
388+ pathspecs : Vec < git:: path:: Spec > ,
389+ } ,
390+ }
373391 }
374392
375393 pub mod mailmap {
You can’t perform that action at this time.
0 commit comments