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


C# Repository.LocalBranchExists方法代码示例

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


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

示例1: IsValid

        /// <summary>
        /// Verifies that the specified path points to a valid repository usable by SyncTool
        /// (a repository with the expected tags and default branches as created by RepositoryInitHelper)
        /// </summary>
        public static bool IsValid(string path)
        {
            // check if the directory exists and is a valid git repository
            if (!Directory.Exists(path) || !Repository.IsValid(path))
            {
                return false;
            }

            using (var repository = new Repository(path))
            {
                // the repository needs to be a bare repository
                if (!repository.Info.IsBare)
                {
                    return false;
                }

                // ensure there is a configuration branch
                if (!repository.LocalBranchExists(RepositoryInitHelper.ConfigurationBranchName))
                {
                    return false;
                }

                // ensure there is a tag for the initial commit
                if (repository.Tags[RepositoryInitHelper.InitialCommitTagName] == null)
                {
                    return false;
                }

                // check if there is a repository info file in the root (on all branches)
                foreach (var localBranch in repository.GetLocalBranches())
                {
                    var gitDirectory = new GitDirectory(null, "Irrelevant", localBranch.Tip);

                    if (!gitDirectory.FileExists(RepositoryInfoFile.RepositoryInfoFileName))
                    {
                        return false;
                    }

                    //TODO: verify content of repository info file
                }                
            }

            return true;

        } 
开发者ID:ap0llo,项目名称:SyncTool,代码行数:49,代码来源:RepositoryVerifier.cs

示例2: CreateGroup_Creates_a_repository_and_pushes_it_to_the_remote_repository

        public void CreateGroup_Creates_a_repository_and_pushes_it_to_the_remote_repository()
        {
            // create a mock for the settings provider
            var settingsProvider = GetGroupSettingsProviderMock().WithEmptyGroupSettings();

            // set up local working directory
            var localDir = Path.Combine(m_TempDirectory.Location, "Local");
            Directory.CreateDirectory(localDir);

            // set up the "remote" repository
            var remoteDir = Path.Combine(m_TempDirectory.Location, "Remote");
            Directory.CreateDirectory(remoteDir);
            Repository.Init(remoteDir, true);

            
            var groupManager = new GitBasedGroupManager(new SingleDirectoryRepositoryPathProvider(localDir), settingsProvider.Object);

            // create a new group
            groupManager.CreateGroup("Group1", remoteDir);

            // creation of groups should not leave behind anything
            Assert.Empty(Directory.GetFileSystemEntries(localDir));

            // assert that the group was actually created in the remote repository
            using (var repository = new Repository(remoteDir))
            {
                Assert.Equal(2, repository.Branches.Count());
                Assert.True(repository.LocalBranchExists(RepositoryInitHelper.ConfigurationBranchName));
                Assert.NotNull(repository.Tags[RepositoryInitHelper.InitialCommitTagName]);
            }

            settingsProvider.Verify(m => m.SaveGroupSettings(It.IsAny<IEnumerable<GroupSettings>>()), Times.AtLeastOnce);
        }
开发者ID:ap0llo,项目名称:SyncTool,代码行数:33,代码来源:GitBasedGroupManagerTest.cs

示例3: Begin_deletes_local_branches_if_the_tracked_brach_was_deleted_in_the_remote_repository

        public void Begin_deletes_local_branches_if_the_tracked_brach_was_deleted_in_the_remote_repository()
        {

            var transaction1 = CreateTransaction();            
            transaction1.Begin();

            m_RemoteRepository.Branches.Remove(s_Branch3);
            
            var transaction2 = CreateCachingTransaction(transaction1.LocalPath);
            transaction2.Begin();

            // assert that the branch has been removed in the local repository and that other branches are still there
            using (var repository = new Repository(transaction2.LocalPath))
            {
                Assert.False(repository.LocalBranchExists(s_Branch3));
                Assert.True(repository.LocalBranchExists(s_Branch2));
                Assert.True(repository.LocalBranchExists("master"));
                
            }
        }
开发者ID:ap0llo,项目名称:SyncTool,代码行数:20,代码来源:CachingGitTransactionTest.cs


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