diff options
author | Jan Melcher <info@yogularm.de> | 2013-11-13 20:48:36 +0400 |
---|---|---|
committer | Jan Melcher <info@yogularm.de> | 2013-11-14 19:31:03 +0400 |
commit | cc3197a91d6286799d8da609bbbac2991c94662e (patch) | |
tree | b72fa4cac1aee8e4fbf90632c7c42ea15548023b /LibGit2Sharp/RefSpec.cs | |
parent | 67433e1e0a8238d208d011bf9f6407451943be7d (diff) |
Enumerate refspecs
The Remote.RefSpecs property allows to enumerate over all refspecs defined for a specific remote.
Diffstat (limited to 'LibGit2Sharp/RefSpec.cs')
-rw-r--r-- | LibGit2Sharp/RefSpec.cs | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/LibGit2Sharp/RefSpec.cs b/LibGit2Sharp/RefSpec.cs new file mode 100644 index 00000000..13f4cb3b --- /dev/null +++ b/LibGit2Sharp/RefSpec.cs @@ -0,0 +1,64 @@ +using System; +using LibGit2Sharp.Core; +using LibGit2Sharp.Core.Handles; + +namespace LibGit2Sharp +{ + /// <summary> + /// A push or fetch reference specification + /// </summary> + public class RefSpec + { + private RefSpec(string refSpec, RefSpecDirection direction, string source, string destination, bool forceUpdate) + { + Ensure.ArgumentNotNullOrEmptyString(refSpec, "refSpec"); + Ensure.ArgumentNotNull(source, "source"); + Ensure.ArgumentNotNull(destination, "destination"); + + Specification = refSpec; + Direction = direction; + Source = source; + Destination = destination; + ForceUpdate = forceUpdate; + } + + /// <summary> + /// Needed for mocking purposes. + /// </summary> + protected RefSpec() + { } + + internal static RefSpec BuildFromPtr(GitRefSpecHandle handle) + { + Ensure.ArgumentNotNull(handle, "handle"); + + return new RefSpec(Proxy.git_refspec_string(handle), Proxy.git_refspec_direction(handle), + Proxy.git_refspec_src(handle), Proxy.git_refspec_dst(handle), Proxy.git_refspec_force(handle)); + } + + /// <summary> + /// Gets the pattern describing the mapping between remote and local references + /// </summary> + public virtual string Specification { get; private set; } + + /// <summary> + /// Indicates whether this <see cref="RefSpec"/> is intended to be used during a Push or Fetch operation + /// </summary> + public virtual RefSpecDirection Direction { get; private set; } + + /// <summary> + /// The source reference specifier + /// </summary> + public virtual string Source { get; private set; } + + /// <summary> + /// The target reference specifier + /// </summary> + public virtual string Destination { get; private set; } + + /// <summary> + /// Indicates whether the destination will be force-updated if fast-forwarding is not possible + /// </summary> + public virtual bool ForceUpdate { get; private set; } + } +} |