1- using System . Diagnostics ;
1+ using System ;
2+ using System . Diagnostics ;
23using System . Globalization ;
34using LibGit2Sharp . Core ;
45using LibGit2Sharp . Core . Handles ;
@@ -11,17 +12,13 @@ namespace LibGit2Sharp
1112 [ DebuggerDisplay ( "{DebuggerDisplay,nq}" ) ]
1213 public class RefSpec
1314 {
14- private RefSpec ( string refSpec , RefSpecDirection direction , string source , string destination , bool forceUpdate )
15- {
16- Ensure . ArgumentNotNullOrEmptyString ( refSpec , "refSpec" ) ;
17- Ensure . ArgumentNotNull ( source , "source" ) ;
18- Ensure . ArgumentNotNull ( destination , "destination" ) ;
15+ readonly Remote remote ;
16+ readonly GitRefSpecHandle handle ;
1917
20- Specification = refSpec ;
21- Direction = direction ;
22- Source = source ;
23- Destination = destination ;
24- ForceUpdate = forceUpdate ;
18+ internal RefSpec ( Remote remote , GitRefSpecHandle handle )
19+ {
20+ this . remote = remote ;
21+ this . handle = handle ;
2522 }
2623
2724 /// <summary>
@@ -30,38 +27,100 @@ private RefSpec(string refSpec, RefSpecDirection direction, string source, strin
3027 protected RefSpec ( )
3128 { }
3229
33- internal static RefSpec BuildFromPtr ( GitRefSpecHandle handle )
34- {
35- Ensure . ArgumentNotNull ( handle , "handle" ) ;
36-
37- return new RefSpec ( Proxy . git_refspec_string ( handle ) , Proxy . git_refspec_direction ( handle ) ,
38- Proxy . git_refspec_src ( handle ) , Proxy . git_refspec_dst ( handle ) , Proxy . git_refspec_force ( handle ) ) ;
39- }
40-
4130 /// <summary>
4231 /// Gets the pattern describing the mapping between remote and local references
4332 /// </summary>
44- public virtual string Specification { get ; private set ; }
33+ public virtual string Specification
34+ {
35+ get
36+ {
37+ return Proxy . git_refspec_string ( this . handle ) ;
38+ }
39+ }
4540
4641 /// <summary>
4742 /// Indicates whether this <see cref="RefSpec"/> is intended to be used during a Push or Fetch operation
4843 /// </summary>
49- public virtual RefSpecDirection Direction { get ; private set ; }
44+ public virtual RefSpecDirection Direction
45+ {
46+ get
47+ {
48+ return Proxy . git_refspec_direction ( this . handle ) ;
49+ }
50+ }
5051
5152 /// <summary>
5253 /// The source reference specifier
5354 /// </summary>
54- public virtual string Source { get ; private set ; }
55+ public virtual string Source
56+ {
57+ get
58+ {
59+ return Proxy . git_refspec_src ( this . handle ) ;
60+ }
61+ }
5562
5663 /// <summary>
5764 /// The target reference specifier
5865 /// </summary>
59- public virtual string Destination { get ; private set ; }
66+ public virtual string Destination
67+ {
68+ get
69+ {
70+ return Proxy . git_refspec_dst ( this . handle ) ;
71+ }
72+ }
6073
6174 /// <summary>
6275 /// Indicates whether the destination will be force-updated if fast-forwarding is not possible
6376 /// </summary>
64- public virtual bool ForceUpdate { get ; private set ; }
77+ public virtual bool ForceUpdate
78+ {
79+ get
80+ {
81+ return Proxy . git_refspec_force ( this . handle ) ;
82+ }
83+ }
84+
85+ /// <summary>
86+ /// Check whether the given reference matches the source (lhs) part of
87+ /// this refspec.
88+ /// </summary>
89+ /// <param name="reference">The reference name to check</param>
90+ public virtual bool SourceMatches ( string reference )
91+ {
92+ return Proxy . git_refspec_src_matches ( handle , reference ) ;
93+ }
94+
95+ /// <summary>
96+ /// Check whether the given reference matches the target (rhs) part of
97+ /// this refspec.
98+ /// </summary>
99+ /// <param name="reference">The reference name to check</param>
100+ public virtual bool DestinationMatches ( string reference )
101+ {
102+ return Proxy . git_refspec_dst_matches ( handle , reference ) ;
103+ }
104+
105+ /// <summary>
106+ /// Perform the transformation described by this refspec on the given
107+ /// reference name (from source to destination).
108+ /// </summary>
109+ /// <param name="reference">The reference name to transform</param>
110+ public virtual string Transform ( string reference )
111+ {
112+ return Proxy . git_refspec_transform ( handle , reference ) ;
113+ }
114+
115+ /// <summary>
116+ /// Perform the reverse of the transformation described by this refspec
117+ /// on the given reference name (from destination to source).
118+ /// </summary>
119+ /// <param name="reference">The reference name to transform</param>
120+ public virtual string ReverseTransform ( string reference )
121+ {
122+ return Proxy . git_refspec_rtransform ( handle , reference ) ;
123+ }
65124
66125 private string DebuggerDisplay
67126 {
0 commit comments