|
2 | 2 | #![forbid(unsafe_code, rust_2018_idioms)]
|
3 | 3 | #![allow(missing_docs)]
|
4 | 4 |
|
5 |
| -use bstr::{BStr, BString}; |
6 |
| - |
7 |
| -/// The way to interpret a refspec. |
8 |
| -#[derive(PartialEq, Eq, Copy, Clone, Hash, Debug)] |
9 |
| -pub enum Mode { |
10 |
| - /// Apply standard rules for refspecs which are including refs with specific rules related to allowing fast forwards of destinations. |
11 |
| - Normal, |
12 |
| - /// Even though according to normal rules a non-fastforward would be denied, override this and reset a ref forcefully in the destination. |
13 |
| - Force, |
14 |
| - /// Instead of considering matching refs included, we consider them excluded. This applies only to the source side of a refspec. |
15 |
| - Negative, |
16 |
| -} |
17 |
| - |
18 |
| -/// What operation to perform with the refspec. |
19 |
| -#[derive(PartialEq, Eq, Copy, Clone, Hash, Debug)] |
20 |
| -pub enum Operation { |
21 |
| - /// The `src` side is local and the `dst` side is remote. |
22 |
| - Push, |
23 |
| - /// The `src` side is remote and the `dst` side is local. |
24 |
| - Fetch, |
25 |
| -} |
26 |
| - |
27 |
| -pub enum Instruction<'a> { |
28 |
| - Push(Push<'a>), |
29 |
| - Fetch(Fetch<'a>), |
30 |
| -} |
31 |
| - |
32 |
| -pub enum Push<'a> { |
33 |
| - /// Push a single ref knowing only one ref name. |
34 |
| - SingleMatching { |
35 |
| - /// The name of the ref to push from `src` to `dest`. |
36 |
| - src_and_dest: &'a BStr, |
37 |
| - /// If true, allow non-fast-forward updates of `dest`. |
38 |
| - allow_non_fast_forward: bool, |
39 |
| - }, |
40 |
| - /// Exclude a single ref. |
41 |
| - ExcludeSingle { |
42 |
| - /// A single full ref name to exclude. |
43 |
| - src: &'a BStr, |
44 |
| - }, |
45 |
| - /// Exclude multiple refs with single `*` glob. |
46 |
| - ExcludeMultipleWithGlob { |
47 |
| - /// A ref pattern with a single `*`. |
48 |
| - src: &'a BStr, |
49 |
| - }, |
50 |
| - /// Push a single ref or refspec to a known destination ref. |
51 |
| - Single { |
52 |
| - /// The source ref or refspec to push. |
53 |
| - src: &'a BStr, |
54 |
| - /// The ref to update with the object from `src`. |
55 |
| - dest: &'a BStr, |
56 |
| - /// If true, allow non-fast-forward updates of `dest`. |
57 |
| - allow_non_fast_forward: bool, |
58 |
| - }, |
59 |
| - /// Push a multiple refs to matching destination refs, with exactly a single glob on both sides. |
60 |
| - MultipleWithGlob { |
61 |
| - /// The source ref to match against all refs for pushing. |
62 |
| - src: &'a BStr, |
63 |
| - /// The ref to update with object obtained from `src`, filling in the `*` with the portion that matched in `src`. |
64 |
| - dest: &'a BStr, |
65 |
| - /// If true, allow non-fast-forward updates of `dest`. |
66 |
| - allow_non_fast_forward: bool, |
67 |
| - }, |
68 |
| -} |
69 |
| - |
70 |
| -pub enum Fetch<'a> { |
71 |
| - Only { |
72 |
| - /// The ref name to fetch on the remote side, without updating the local side. |
73 |
| - src: &'a BStr, |
74 |
| - }, |
75 |
| - /// Exclude a single ref. |
76 |
| - ExcludeSingle { |
77 |
| - /// A single full ref name to exclude. |
78 |
| - src: &'a BStr, |
79 |
| - }, |
80 |
| - /// Exclude multiple refs with single `*` glob. |
81 |
| - ExcludeMultipleWithGlob { |
82 |
| - /// A ref pattern with a single `*`. |
83 |
| - src: &'a BStr, |
84 |
| - }, |
85 |
| - AndUpdateSingle { |
86 |
| - /// The ref name to fetch on the remote side. |
87 |
| - src: &'a BStr, |
88 |
| - /// The local destination to update with what was fetched. |
89 |
| - dest: &'a BStr, |
90 |
| - /// If true, allow non-fast-forward updates of `dest`. |
91 |
| - allow_non_fast_forward: bool, |
92 |
| - }, |
93 |
| - /// Similar to `FetchAndUpdate`, but src and destination contain a single glob to fetch and update multiple refs. |
94 |
| - AndUpdateMultipleWithGlob { |
95 |
| - /// The ref glob to match against all refs on the remote side for fetching. |
96 |
| - src: &'a BStr, |
97 |
| - /// The local destination to update with what was fetched by replacing the single `*` with the matching portion from `src`. |
98 |
| - dest: &'a BStr, |
99 |
| - /// If true, allow non-fast-forward updates of `dest`. |
100 |
| - allow_non_fast_forward: bool, |
101 |
| - }, |
102 |
| -} |
| 5 | +pub mod parse; |
| 6 | +pub use parse::function::parse; |
103 | 7 |
|
104 | 8 | /// A refspec with references to the memory it was parsed from.
|
105 | 9 | #[derive(PartialEq, Eq, Copy, Clone, Hash, Debug)]
|
106 | 10 | pub struct RefSpecRef<'a> {
|
107 | 11 | mode: Mode,
|
108 | 12 | op: Operation,
|
109 |
| - src: Option<&'a BStr>, |
110 |
| - dest: Option<&'a BStr>, |
| 13 | + src: Option<&'a bstr::BStr>, |
| 14 | + dest: Option<&'a bstr::BStr>, |
111 | 15 | }
|
112 | 16 |
|
113 | 17 | /// An owned refspec.
|
114 | 18 | #[derive(PartialEq, Eq, Clone, Hash, Debug)]
|
115 | 19 | pub struct RefSpec {
|
116 | 20 | mode: Mode,
|
117 | 21 | op: Operation,
|
118 |
| - src: Option<BString>, |
119 |
| - dest: Option<BString>, |
| 22 | + src: Option<bstr::BString>, |
| 23 | + dest: Option<bstr::BString>, |
120 | 24 | }
|
121 | 25 |
|
122 |
| -pub mod parse; |
123 |
| -pub use parse::function::parse; |
| 26 | +mod types; |
| 27 | +pub use types::{Instruction, Mode, Operation}; |
124 | 28 |
|
125 | 29 | mod spec {
|
126 | 30 | use crate::{Instruction, Mode, RefSpec, RefSpecRef};
|
|
0 commit comments