-
-
Notifications
You must be signed in to change notification settings - Fork 313
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
basic infrastructure for delegate implementation (#427)
- Loading branch information
Showing
2 changed files
with
66 additions
and
10 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,11 +1,69 @@ | ||
use git::revision::spec::parse::{delegate, Delegate}; | ||
use git_repository as git; | ||
use git_repository::bstr::BStr; | ||
use git_repository::hash::Prefix; | ||
use git_repository::revision::spec::parse::delegate::{PeelTo, ReflogLookup, SiblingBranch, Traversal}; | ||
use git_repository::revision::spec::Kind; | ||
use std::ffi::OsString; | ||
|
||
pub fn explain( | ||
_repo: git::Repository, | ||
_spec: OsString, | ||
mut _out: impl std::io::Write, | ||
mut _err: impl std::io::Write, | ||
) -> anyhow::Result<()> { | ||
Ok(()) | ||
struct Explain<'a> { | ||
out: &'a mut dyn std::io::Write, | ||
} | ||
|
||
impl<'a> delegate::Revision for Explain<'a> { | ||
fn find_ref(&mut self, name: &BStr) -> Option<()> { | ||
todo!() | ||
} | ||
|
||
fn disambiguate_prefix(&mut self, prefix: Prefix) -> Option<()> { | ||
todo!() | ||
} | ||
|
||
fn reflog(&mut self, query: ReflogLookup) -> Option<()> { | ||
todo!() | ||
} | ||
|
||
fn nth_checked_out_branch(&mut self, branch_no: usize) -> Option<()> { | ||
todo!() | ||
} | ||
|
||
fn sibling_branch(&mut self, kind: SiblingBranch) -> Option<()> { | ||
todo!() | ||
} | ||
} | ||
|
||
impl<'a> delegate::Navigate for Explain<'a> { | ||
fn traverse(&mut self, kind: Traversal) -> Option<()> { | ||
todo!() | ||
} | ||
|
||
fn peel_until(&mut self, kind: PeelTo<'_>) -> Option<()> { | ||
todo!() | ||
} | ||
|
||
fn find(&mut self, regex: &BStr, negated: bool) -> Option<()> { | ||
todo!() | ||
} | ||
|
||
fn index_lookup(&mut self, path: &BStr, stage: u8) -> Option<()> { | ||
todo!() | ||
} | ||
} | ||
|
||
impl<'a> delegate::Kind for Explain<'a> { | ||
fn kind(&mut self, kind: Kind) -> Option<()> { | ||
todo!() | ||
} | ||
} | ||
|
||
impl<'a> Delegate for Explain<'a> { | ||
fn done(&mut self) { | ||
todo!() | ||
} | ||
} | ||
|
||
pub fn explain(_repo: git::Repository, spec: OsString, mut out: impl std::io::Write) -> anyhow::Result<()> { | ||
let mut explain = Explain { out: &mut out }; | ||
let spec = git::path::os_str_into_bstr(&spec)?; | ||
git::revision::spec::parse(spec, &mut explain).map_err(anyhow::Error::from) | ||
} |
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