Welcome to mirror list, hosted at ThFree Co, Russian Federation.

RefSpec.cs « LibGit2Sharp - github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5534bd54717aa469f8080bde8c71486a493f2497 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using System;
using System.Diagnostics;
using System.Globalization;
using LibGit2Sharp.Core;
using LibGit2Sharp.Core.Handles;

namespace LibGit2Sharp
{
    /// <summary>
    /// A push or fetch reference specification
    /// </summary>
    [DebuggerDisplay("{DebuggerDisplay,nq}")]
    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; }

        private string DebuggerDisplay
        {
            get
            {
                return string.Format(CultureInfo.InvariantCulture,
                    "{0}", Specification);
            }
        }
    }
}