History

frame for basic parsing (#450)

Sebastian Thiel committed 4 years ago

Commit b9a4bdc1 parent 5c823dc3 files · +51 −0Browse files

Showing the changes to git-refspec/src (2 of 3 files). Show all

Unified · Split

2 files
  1. git-refspec/src/lib.rs +5 −0
  2. git-refspec/src/parse.rs +18 −0
git-refspec/src/lib.rs+5−0
@@ -7,6 +7,8 @@ use bstr::{BStr, BString}; · 6 unmodified lines
7/// The way to interpret a refspec.7/// The way to interpret a refspec.
8#[derive(PartialEq, Eq, Copy, Clone, Hash, Debug)]8#[derive(PartialEq, Eq, Copy, Clone, Hash, Debug)]
9pub enum Mode {9pub enum Mode {
10 /// Apply standard rules for refspecs which are including refs with specific rules related to allowing fast forwards of destinations.
11 Normal,
10 /// Even though according to normal rules a non-fastforward would be denied, override this and reset a ref forcefully in the destination.12 /// Even though according to normal rules a non-fastforward would be denied, override this and reset a ref forcefully in the destination.
11 Force,13 Force,
12 /// Instead of considering matching refs included, we consider them excluded. This applies only to the source side of a refspec.14 /// Instead of considering matching refs included, we consider them excluded. This applies only to the source side of a refspec.
@@ -40,6 +42,9 @@ pub struct RefSpec { · 27 unmodified lines
40 dest: Option<BString>,42 dest: Option<BString>,
41}43}
42 44
45pub mod parse;
46pub use parse::function::parse;
47
43mod spec {48mod spec {
44 use crate::{RefSpec, RefSpecRef};49 use crate::{RefSpec, RefSpecRef};
45 50
git-refspec/src/parse.rs+18−0
@@ -0,0 +1,18 @@
1#[derive(Debug, thiserror::Error)]
2pub enum Error {
3 #[error("Empty refspecs are invalid")]
4 Empty,
5 #[error("Negative refspecs cannot have destinations as they exclude sources")]
6 NegativeWithDestination,
7}
8
9pub(crate) mod function {
10 use crate::parse::Error;
11 use crate::{Operation, RefSpecRef};
12 use bstr::BStr;
13
14 /// Parse `spec` for use in `operation` and return it if it is valid.
15 pub fn parse(mut _spec: &BStr, _operation: Operation) -> Result<RefSpecRef<'_>, Error> {
16 todo!()
17 }
18}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t