Esempio n. 1
0
        private static Commit LookUpCommit(IRepository repository, string committish)
        {
            GitObject obj = repository.Lookup(committish);

            Ensure.GitObjectIsNotNull(obj, committish);
            return(obj.Peel <Commit>(true));
        }
Esempio n. 2
0
        /// <summary>
        /// Creates an annotated tag with the specified name.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="objectish">Revparse spec for the target object.</param>
        /// <param name="tagger">The tagger.</param>
        /// <param name="message">The message.</param>
        /// <param name="allowOverwrite">True to allow silent overwriting a potentially existing tag, false otherwise.</param>
        public virtual Tag Add(string name, string objectish, Signature tagger, string message, bool allowOverwrite)
        {
            Ensure.ArgumentNotNullOrEmptyString(objectish, "target");

            GitObject objectToTag = repo.Lookup(objectish, GitObjectType.Any, LookUpOptions.ThrowWhenNoGitObjectHasBeenFound);

            return(Add(name, objectToTag, tagger, message, allowOverwrite));
        }
Esempio n. 3
0
        /// <summary>
        /// Creates a lightweight tag with the specified name.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="target">The target <see cref="GitObject"/>.</param>
        /// <param name="allowOverwrite">True to allow silent overwriting a potentially existing tag, false otherwise.</param>
        /// <returns>The added <see cref="Tag"/>.</returns>
        public virtual Tag Add(string name, GitObject target, bool allowOverwrite)
        {
            Ensure.ArgumentNotNullOrEmptyString(name, "name");
            Ensure.ArgumentNotNull(target, "target");

            Proxy.git_tag_create_lightweight(repo.Handle, name, target, allowOverwrite);

            return(this[name]);
        }
Esempio n. 4
0
        /// <summary>
        /// Updates the target of a direct reference.
        /// </summary>
        /// <param name="directRef">The direct reference which target should be updated.</param>
        /// <param name="objectish">The revparse spec of the target.</param>
        /// <param name="logMessage">The optional message to log in the <see cref="ReflogCollection"/></param>
        /// <returns>A new <see cref="Reference"/>.</returns>
        public virtual Reference UpdateTarget(Reference directRef, string objectish, string logMessage)
        {
            Ensure.ArgumentNotNull(directRef, "directRef");
            Ensure.ArgumentNotNull(objectish, "objectish");

            GitObject target = repo.Lookup(objectish);

            Ensure.GitObjectIsNotNull(target, objectish);

            return(UpdateTarget(directRef, target.Id, logMessage));
        }
Esempio n. 5
0
        /// <summary>
        /// Creates an annotated tag with the specified name.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="target">The target <see cref="GitObject"/>.</param>
        /// <param name="tagger">The tagger.</param>
        /// <param name="message">The message.</param>
        /// <param name="allowOverwrite">True to allow silent overwriting a potentially existing tag, false otherwise.</param>
        /// <returns>The added <see cref="Tag"/>.</returns>
        public virtual Tag Add(string name, GitObject target, Signature tagger, string message, bool allowOverwrite)
        {
            Ensure.ArgumentNotNullOrEmptyString(name, "name");
            Ensure.ArgumentNotNull(target, "target");
            Ensure.ArgumentNotNull(tagger, "tagger");
            Ensure.ArgumentNotNull(message, "message");

            string prettifiedMessage = Proxy.git_message_prettify(message, null);

            Proxy.git_tag_create(repo.Handle, name, target, tagger, prettifiedMessage, allowOverwrite);

            return(this[name]);
        }
Esempio n. 6
0
        private static ObjectId DereferenceToCommit(Repository repo, string identifier)
        {
            var options = LookUpOptions.DereferenceResultToCommit;

            if (!AllowOrphanReference(repo, identifier))
            {
                options |= LookUpOptions.ThrowWhenNoGitObjectHasBeenFound;
            }

            // TODO: Should we check the type? Git-log allows TagAnnotation oid as parameter. But what about Blobs and Trees?
            GitObject commit = repo.Lookup(identifier, GitObjectType.Any, options);

            return(commit != null ? commit.Id : null);
        }
Esempio n. 7
0
        private GitObject RetrieveTreeEntryTarget()
        {
            switch (TargetType)
            {
            case TreeEntryTargetType.GitLink:
                return(new GitLink(repo, targetOid));

            case TreeEntryTargetType.Blob:
            case TreeEntryTargetType.Tree:
                return(GitObject.BuildFrom(repo, targetOid, TargetType.ToGitObjectType(), Path));

            default:
                throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture,
                                                                  "TreeEntry target of type '{0}' is not supported.",
                                                                  TargetType));
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Gets the <see cref="Stash"/> corresponding to the specified index (0 being the most recent one).
        /// </summary>
        public virtual Stash this[int index]
        {
            get
            {
                if (index < 0)
                {
                    throw new ArgumentOutOfRangeException("index", "The passed index must be a positive integer.");
                }

                GitObject stashCommit = repo.Lookup(string.Format(CultureInfo.InvariantCulture,
                                                                  "stash@{{{0}}}",
                                                                  index),
                                                    GitObjectType.Commit,
                                                    LookUpOptions.None);

                return(stashCommit == null
                    ? null
                    : new Stash(repo, stashCommit.Id, index));
            }
        }
Esempio n. 9
0
 /// <summary>
 /// Creates a lightweight tag with the specified name.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="target">The target <see cref="GitObject"/>.</param>
 /// <returns>The added <see cref="Tag"/>.</returns>
 public virtual Tag Add(string name, GitObject target)
 {
     return(Add(name, target, false));
 }
Esempio n. 10
0
 /// <summary>
 /// Creates an annotated tag with the specified name.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="target">The target <see cref="GitObject"/>.</param>
 /// <param name="tagger">The tagger.</param>
 /// <param name="message">The message.</param>
 /// <returns>The added <see cref="Tag"/>.</returns>
 public virtual Tag Add(string name, GitObject target, Signature tagger, string message)
 {
     return(Add(name, target, tagger, message, false));
 }