当前位置: 首页>>代码示例>>C#>>正文


C# Repository.ApplyTag方法代码示例

本文整理汇总了C#中Repository.ApplyTag方法的典型用法代码示例。如果您正苦于以下问题:C# Repository.ApplyTag方法的具体用法?C# Repository.ApplyTag怎么用?C# Repository.ApplyTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Repository的用法示例。


在下文中一共展示了Repository.ApplyTag方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CanFollowFirstParent

        public void CanFollowFirstParent()
        {
            string path = SandboxStandardTestRepo();
            using (var repo = new Repository(path))
            {
                var branch = repo.CreateBranch("branch");

                // Make an earlier tag on master
                repo.Commit("A", Constants.Signature, Constants.Signature, new CommitOptions { AllowEmptyCommit = true });
                repo.ApplyTag("firstParentTag");

                // Make a later tag on branch
                Commands.Checkout(repo, branch);
                repo.Commit("B", Constants.Signature, Constants.Signature, new CommitOptions { AllowEmptyCommit = true });
                repo.ApplyTag("mostRecentTag");

                Commands.Checkout(repo, "master");
                repo.Commit("C", Constants.Signature, Constants.Signature, new CommitOptions { AllowEmptyCommit = true });
                repo.Merge(branch, Constants.Signature, new MergeOptions() { FastForwardStrategy = FastForwardStrategy.NoFastForward });

                // With OnlyFollowFirstParent = false, the most recent tag reachable should be returned
                Assert.Equal("mostRecentTag-3-gf17be71", repo.Describe(repo.Head.Tip, new DescribeOptions { OnlyFollowFirstParent = false, Strategy = DescribeStrategy.Tags }));

                // With OnlyFollowFirstParent = true, the most recent tag on the current branch should be returned
                Assert.Equal("firstParentTag-2-gf17be71", repo.Describe(repo.Head.Tip, new DescribeOptions { OnlyFollowFirstParent = true, Strategy = DescribeStrategy.Tags }));

            }
        }
开发者ID:PKRoma,项目名称:libgit2sharp,代码行数:28,代码来源:DescribeFixture.cs

示例2: AddTag

 protected static void AddTag(Repository repo, string tagName)
 {
     var randomFile = Path.Combine(repo.Info.WorkingDirectory, Guid.NewGuid().ToString());
     File.WriteAllText(randomFile, string.Empty);
     repo.Index.Stage(randomFile);
     var sign = SignatureBuilder.SignatureNow();
     repo.ApplyTag(tagName, repo.Head.Tip.Id.Sha, sign, "foo");
 }
开发者ID:hbre,项目名称:GitVersion,代码行数:8,代码来源:Lg2sHelperBase.cs

示例3: CanDescribeACommit

        public void CanDescribeACommit()
        {
            string path = SandboxBareTestRepo();
            using (var repo = new Repository(path))
            {
                // No annotated tags can be used to describe "master"
                var masterTip = repo.Branches["master"].Tip;
                Assert.Throws<NotFoundException>(() => repo.Describe(masterTip));
                Assert.Equal("4c062a6", repo.Describe(masterTip,
                    new DescribeOptions { UseCommitIdAsFallback = true }));
                Assert.Equal("4c06", repo.Describe(masterTip,
                    new DescribeOptions { UseCommitIdAsFallback = true, MinimumCommitIdAbbreviatedSize = 2 }));

                // No lightweight tags can either be used to describe "master"
                Assert.Throws<NotFoundException>(() => repo.Describe(masterTip,
                    new DescribeOptions{ Strategy = DescribeStrategy.Tags }));

                repo.ApplyTag("myTag", "5b5b025afb0b4c913b4c338a42934a3863bf3644");
                Assert.Equal("myTag-5-g4c062a6", repo.Describe(masterTip,
                    new DescribeOptions { Strategy = DescribeStrategy.Tags }));
                Assert.Equal("myTag-5-g4c062a636", repo.Describe(masterTip,
                    new DescribeOptions { Strategy = DescribeStrategy.Tags, MinimumCommitIdAbbreviatedSize = 9 }));
                Assert.Equal("myTag-4-gbe3563a", repo.Describe(masterTip.Parents.Single(),
                    new DescribeOptions { Strategy = DescribeStrategy.Tags }));

                Assert.Equal("heads/master", repo.Describe(masterTip,
                    new DescribeOptions { Strategy = DescribeStrategy.All }));
                Assert.Equal("heads/packed-test-3-gbe3563a", repo.Describe(masterTip.Parents.Single(),
                    new DescribeOptions { Strategy = DescribeStrategy.All }));

                // "test" branch points to an annotated tag (also named "test")
                // Let's rename the branch to ease the understanding of what we
                // are exercising.

                repo.Branches.Rename(repo.Branches["test"], "ForLackOfABetterName");

                var anotherTip = repo.Branches["ForLackOfABetterName"].Tip;
                Assert.Equal("test", repo.Describe(anotherTip));
                Assert.Equal("test-0-g7b43849", repo.Describe(anotherTip,
                    new DescribeOptions{ AlwaysRenderLongFormat = true }));
            }
        }
开发者ID:PKRoma,项目名称:libgit2sharp,代码行数:42,代码来源:DescribeFixture.cs

示例4: CanCreateAnAnnotatedTagPointingToATagAnnotation

        public void CanCreateAnAnnotatedTagPointingToATagAnnotation()
        {
            TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
            using (var repo = new Repository(path.RepositoryPath))
            {
                Tag annotatedTag = repo.Tags["e90810b"];
                TagAnnotation annotation = annotatedTag.Annotation;

                Tag tag = repo.ApplyTag("annotatedtag-tag", annotation.Sha, signatureNtk, "A new annotation");
                tag.ShouldNotBeNull();
                tag.IsAnnotated.ShouldBeTrue();
                tag.Annotation.Target.Id.ShouldEqual(annotation.Id);
                tag.Annotation.ShouldNotEqual(annotation);

                repo.Tags[tag.Name].ShouldEqual(tag);
            }
        }
开发者ID:redoz,项目名称:libgit2sharp,代码行数:17,代码来源:TagFixture.cs

示例5: FeedTheRepository

        private static void FeedTheRepository(Repository repo)
        {
            string fullPath = Path.Combine(repo.Info.WorkingDirectory, "a.txt");
            File.WriteAllText(fullPath, "Hello\n");
            repo.Index.Stage(fullPath);
            repo.Commit("Initial commit", Constants.Signature, Constants.Signature);
            repo.ApplyTag("mytag");

            File.AppendAllText(fullPath, "World\n");
            repo.Index.Stage(fullPath);

            Signature shiftedSignature = Constants.Signature.TimeShift(TimeSpan.FromMinutes(1));
            repo.Commit("Update file", shiftedSignature, shiftedSignature);
            repo.CreateBranch("mybranch");

            repo.Checkout("mybranch");

            Assert.False(repo.Index.RetrieveStatus().IsDirty);
        }
开发者ID:TiThompson,项目名称:libgit2sharp,代码行数:19,代码来源:ResetHeadFixture.cs

示例6: CanEnumerateCommitsFromATagWhichPointsToATree

        public void CanEnumerateCommitsFromATagWhichPointsToATree()
        {
            string path = CloneBareTestRepo();
            using (var repo = new Repository(path))
            {
                string headTreeSha = repo.Head.Tip.Tree.Sha;

                Tag tag = repo.ApplyTag("point_to_tree", headTreeSha);

                AssertEnumerationOfCommitsInRepo(repo,
                    r => new Filter { Since = tag },
                    new string[] { });
            }
        }
开发者ID:TiThompson,项目名称:libgit2sharp,代码行数:14,代码来源:CommitFixture.cs

示例7: CanCreateATagPointingToABlob

        public void CanCreateATagPointingToABlob()
        {
            TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
            using (var repo = new Repository(path.RepositoryPath))
            {
                Commit headCommit = repo.Head.Tip;
                Blob blob = headCommit.Tree.Blobs.First();

                Tag tag = repo.ApplyTag("blob-tag", blob.Sha);
                Assert.NotNull(tag);
                Assert.False(tag.IsAnnotated);
                Assert.Equal(blob.Id, tag.Target.Id);

                Assert.Equal(blob, repo.Lookup(tag.Target.Id));
                Assert.Equal(tag, repo.Tags[tag.Name]);
            }
        }
开发者ID:roend83,项目名称:libgit2sharp,代码行数:17,代码来源:TagFixture.cs

示例8: CanCreateAnAnnotatedTagWithAnEmptyMessage

 public void CanCreateAnAnnotatedTagWithAnEmptyMessage()
 {
     TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
     using (var repo = new Repository(path.RepositoryPath))
     {
         Tag newTag = repo.ApplyTag("empty-annotated-tag", signatureNtk, string.Empty);
         Assert.NotNull(newTag);
         Assert.True(newTag.IsAnnotated);
         Assert.Equal(string.Empty, newTag.Annotation.Message);
     }
 }
开发者ID:roend83,项目名称:libgit2sharp,代码行数:11,代码来源:TagFixture.cs

示例9: CanCreateATagUsingHead

        public void CanCreateATagUsingHead()
        {
            TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
            using (var repo = new Repository(path.RepositoryPath))
            {
                Tag tag = repo.ApplyTag("mytag", "HEAD");
                tag.ShouldNotBeNull();

                tag.Target.Id.ShouldEqual(repo.Head.Tip.Id);

                Tag retrievedTag = repo.Tags[tag.CanonicalName];
                tag.ShouldEqual(retrievedTag);
            }
        }
开发者ID:redoz,项目名称:libgit2sharp,代码行数:14,代码来源:TagFixture.cs

示例10: BuildTemporaryCloneOfTestRepo

        public void CreatingALightweightTagPointingToATagAnnotationGeneratesAnAnnotatedTagReusingThePointedAtTagAnnotation()
        {
            TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
            using (var repo = new Repository(path.RepositoryPath))
            {
                Tag annotatedTag = repo.Tags["e90810b"];
                TagAnnotation annotation = annotatedTag.Annotation;

                Tag tag = repo.ApplyTag("lightweight-tag", annotation.Sha);
                tag.ShouldNotBeNull();
                tag.IsAnnotated.ShouldBeTrue();
                tag.Target.Id.ShouldEqual(annotation.Target.Id);
                tag.Annotation.ShouldEqual(annotation);

                repo.Lookup(tag.Annotation.Id).ShouldEqual(annotation);
                repo.Tags[tag.Name].ShouldEqual(tag);
            }
        }
开发者ID:redoz,项目名称:libgit2sharp,代码行数:18,代码来源:TagFixture.cs

示例11: CreatingATagInAEmptyRepositoryThrows

        public void CreatingATagInAEmptyRepositoryThrows()
        {
            using (var scd = new SelfCleaningDirectory())
            {
                var dir = Repository.Init(scd.DirectoryPath);

                using (var repo = new Repository(dir))
                {
                    Assert.Throws<ApplicationException>(() => repo.ApplyTag("mynotag"));
                }
            }
        }
开发者ID:paulcbetts,项目名称:libgit2sharp,代码行数:12,代码来源:TagFixture.cs

示例12: CreatingATagWithANonValidNameShouldFail

 public void CreatingATagWithANonValidNameShouldFail()
 {
     using (var path = new TemporaryCloneOfTestRepo())
     using (var repo = new Repository(path.RepositoryPath))
     {
         Assert.Throws<ArgumentException>(() => repo.ApplyTag(""));
         Assert.Throws<ApplicationException>(() => repo.ApplyTag(".othertag"));
         Assert.Throws<ApplicationException>(() => repo.ApplyTag("other tag"));
         Assert.Throws<ApplicationException>(() => repo.ApplyTag("othertag^"));
         Assert.Throws<ApplicationException>(() => repo.ApplyTag("other~tag"));
     }
 }
开发者ID:paulcbetts,项目名称:libgit2sharp,代码行数:12,代码来源:TagFixture.cs

示例13: CreatingATagForAnUnknowObjectIdShouldFail

 public void CreatingATagForAnUnknowObjectIdShouldFail()
 {
     using (var path = new TemporaryCloneOfTestRepo())
     using (var repo = new Repository(path.RepositoryPath))
     {
         Assert.Throws<ApplicationException>(() => repo.ApplyTag("mytagnorev", Constants.UnknownSha));
     }
 }
开发者ID:paulcbetts,项目名称:libgit2sharp,代码行数:8,代码来源:TagFixture.cs

示例14: CreatingATagForAnUnknowReferenceShouldFail

 public void CreatingATagForAnUnknowReferenceShouldFail()
 {
     using (var path = new TemporaryCloneOfTestRepo())
     using (var repo = new Repository(path.RepositoryPath))
     {
         Assert.Throws<ApplicationException>(() => repo.ApplyTag("mytagnorev", "aaaaaaaaaaa"));
     }
 }
开发者ID:paulcbetts,项目名称:libgit2sharp,代码行数:8,代码来源:TagFixture.cs

示例15: CreatingADuplicateTagShouldFail

        public void CreatingADuplicateTagShouldFail()
        {
            using (var path = new TemporaryCloneOfTestRepo())
            using (var repo = new Repository(path.RepositoryPath))
            {
                repo.ApplyTag("mytag");

                Assert.Throws<ApplicationException>(() => repo.ApplyTag("mytag"));
            }
        }
开发者ID:paulcbetts,项目名称:libgit2sharp,代码行数:10,代码来源:TagFixture.cs


注:本文中的Repository.ApplyTag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。