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


C# Repository.CreateBranch方法代码示例

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


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

示例1: AbstractGitTransactionTest

 protected AbstractGitTransactionTest()
 {
     RemoteRepositoryPath = Path.Combine(m_TempDirectory.Directory.Location, "Remote");
     
     RepositoryInitHelper.InitializeRepository(RemoteRepositoryPath);
     
     m_RemoteRepository = new Repository(RemoteRepositoryPath);
     m_RemoteRepository.CreateBranch(s_Branch2, m_RemoteRepository.Commits.Single());
     m_RemoteRepository.CreateBranch(s_Branch3, m_RemoteRepository.Commits.Single());
 }
开发者ID:ap0llo,项目名称:SyncTool,代码行数:10,代码来源:AbstractGitTransactionTest.cs

示例2: GitBasedFileSystemSnapshotTest

        public GitBasedFileSystemSnapshotTest()
        {
            RepositoryInitHelper.InitializeRepository(m_TempDirectory.Location);

            using (var repo = new Repository(m_TempDirectory.Location))
            {
                repo.CreateBranch(new BranchName("branch", "name"), repo.Commits.Single());
            }

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

示例3: GitBasedFileSystemHistoryTest

        public GitBasedFileSystemHistoryTest()
        { 
            RepositoryInitHelper.InitializeRepository(m_TempDirectory.Location);

            m_Repository = new Repository(m_TempDirectory.Location);
            var branchName = new BranchName("", "branch1");
            m_Repository.CreateBranch(branchName, m_Repository.GetAllCommits().Single());

            m_Instance = new GitBasedFileSystemHistory(m_Repository, branchName);

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

示例4: Init

 public void Init(DeclarationOfExistence doe)
 {
     if (!_directory.Exists)
     {
         _directory.Create();
     }
     if (!_directory.GetFiles().Any() && !_directory.GetDirectories().Any())
     {
         // Directory is empty
         Repository.Init(_directory.FullName, isBare: true);
         using (var repo = new Repository(_directory.FullName))
         {
             InitCoreTags(repo);
             Commit doeCommit = CreateDeclarationOfExistence(repo, doe);
             repo.CreateBranch(CONTROL_BRANCH, doeCommit);
             repo.CreateBranch(CONTENT_BRANCH, doeCommit);
         }
     }
     else
     {
         throw new BastionException(string.Format("{0} has already been initialized", _directory.FullName));
     }
 }
开发者ID:rmichela,项目名称:BastionPrototype,代码行数:23,代码来源:Bastion.cs

示例5: InitializeRepository

        /// <summary>
        /// Initializes a new bare repository at the specified location, adds a repository info file to the root directory
        /// and tags the initial commit with he value of <see cref="InitialCommitTagName"/>
        /// </summary>
        public static void InitializeRepository(string location)
        {            
            // initialize a bare repository
            Repository.Init(location, true);

            var directoryCreator = new LocalItemCreator();

            // clone the repository, add initial commit and push the changes back to the actual repository
            using (var tempDirectory = directoryCreator.CreateTemporaryDirectory())
            {
                var clonedRepoPath = Repository.Clone(location, tempDirectory.Directory.Location);

                var repositoryInfoFile = new RepositoryInfoFile(tempDirectory.Directory);

                // add a empty file to the repository
                directoryCreator.CreateFile(repositoryInfoFile, tempDirectory.Directory.Location);

                // commit and push the file to the bare repository we created
                using (var clonedRepo = new Repository(clonedRepoPath))
                {
                    var signature = SignatureHelper.NewSignature();

                    clonedRepo.Stage(repositoryInfoFile.Name);
                    clonedRepo.Commit("Initial Commit", signature, signature, new CommitOptions());                    

                    clonedRepo.Network.Push(clonedRepo.Network.Remotes["origin"], @"refs/heads/master");                    
                }
            }

            //create the configuration branch pointing to the initial commit
            using (var repository = new Repository(location))
            {
                repository.CreateBranch(ConfigurationBranchName.ToString(), repository.GetAllCommits().Single());
                repository.Tags.Add(InitialCommitTagName, repository.GetAllCommits().Single());
            }
        }
开发者ID:ap0llo,项目名称:SyncTool,代码行数:40,代码来源:RepositoryInitHelper.cs

示例6: SetupMasterBranch

 private static void SetupMasterBranch(Repository repository, string masterName, Signature author)
 {
     //We know we have a master branch , so check to see if the gitflow master is different and if it is
     Branch branch;
     if (masterName != "master" && !repository.TryGetBranch(masterName, out branch))
     {
         repository.CreateBranch(masterName);
     }
 }
开发者ID:jzoss,项目名称:libgitflow2sharp,代码行数:9,代码来源:GitFlowExtensions.Init.cs

示例7: CreateLocalBranches

        /// <summary>
        /// Creates local tracking branches for all remote branches
        /// </summary>
        protected void CreateLocalBranches()
        {
            using (var repository = new Repository(LocalPath))
            {
                // for every remote branch, create a local branch if it does not already exist
                foreach (var remoteBranch in repository.Branches.GetRemoteBranches())
                {
                    var branchName = remoteBranch.FriendlyName.Replace($"{s_Origin}/", "");

                    var localBranch = repository.Branches[branchName] ?? repository.CreateBranch(branchName, remoteBranch.Tip);

                    // set up the local branch to track the remote branch
                    repository.Branches.Update(localBranch, b => b.TrackedBranch = remoteBranch.CanonicalName);
                }
            }
        }
开发者ID:ap0llo,项目名称:SyncTool,代码行数:19,代码来源:AbstractGitTransaction.cs

示例8: NewPost

        public void NewPost(Post post)
        {
            using (var repo = new Repository(_directory.FullName))
            {
                var json = JsonConvert.SerializeObject(post);
                var sig = new Signature(post.Author.Name, post.Author.Identifier, post.Timestamp);

                // Create post structure
                var votesDir = repo.ObjectDatabase.CreateTree(new TreeDefinition());
                var repliesDir = repo.ObjectDatabase.CreateTree(new TreeDefinition());
                var postRoot = new TreeDefinition();
                postRoot.Add(VOTES_DIR, votesDir);
                postRoot.Add(REPLIES_DIR, repliesDir);

                var commit = CommitToBranch(repo, CONTENT_BRANCH, json, sig, repo.ObjectDatabase.CreateTree(postRoot));
                // Create a named branch for all future content on this post
                repo.CreateBranch(commit.Sha, commit);
            }
        }
开发者ID:rmichela,项目名称:BastionPrototype,代码行数:19,代码来源:Bastion.cs

示例9: ResetBuildBranchToTag

        private static void ResetBuildBranchToTag(Repository repository, ILogger logger, VersionLabel versionLabel, Tag versionLabelTag)
        {
            var buildBranch =
                (from branch in repository.Branches
                 where branch.FriendlyName == BuildBranchName
                 select branch).SingleOrDefault();
            if (buildBranch == null)
            {
                logger.Log($"The branch '{BuildBranchName}' doesn't exist: creating it and resetting it to '{versionLabel.Raw}'");

                // If the build branch doesn't exist, create it and check it out
                buildBranch = repository.CreateBranch(BuildBranchName, versionLabelTag.Target as Commit);
                repository.Checkout(buildBranch, new CheckoutOptions() { CheckoutModifiers = CheckoutModifiers.Force });
            }
            else
            {
                logger.Log($"The branch '{BuildBranchName}' already exists: checking it out and resetting it to '{versionLabel.Raw}'");

                // If the build branch exists, check it out and do an hard reset
                repository.Checkout(buildBranch, new CheckoutOptions() { CheckoutModifiers = CheckoutModifiers.Force });
                repository.Reset(ResetMode.Hard, versionLabelTag.Target as Commit);
            }
        }
开发者ID:Bhaal22,项目名称:Msbuild.GitCloneTask,代码行数:23,代码来源:VersionResolver.cs

示例10: CanReuseLocalRepository_returns_false_if_the_repository_contains_unpublished_branches

        public void CanReuseLocalRepository_returns_false_if_the_repository_contains_unpublished_branches()
        {
            var transaction1 = CreateTransaction();
            transaction1.Begin();
            using (var repository = new Repository(transaction1.LocalPath))
            {
                repository.CreateBranch("newBranch", repository.GetAllCommits().Single());
            }

            //do not commit the changes from the transaction (leaves the local directory intact (with a new commit))        

            var cachingTransaction = CreateCachingTransaction(transaction1.LocalPath);
            Assert.False(cachingTransaction.CanReuseLocalRepository());
        }
开发者ID:ap0llo,项目名称:SyncTool,代码行数:14,代码来源:CachingGitTransactionTest.cs

示例11: HandleFixedVersioning_Commit

        protected virtual void HandleFixedVersioning_Commit(Dependency dependency, Repository otherRepository)
        {
            var dependencyCommit = otherRepository.Lookup(dependency.Commit) as Commit;
            if (dependencyCommit == null)
                throw new InvalidOperationException($"Dependency {dependency}: Commit '{dependency.Commit}' is invalid");

            var buildBranch =
                (from branch in otherRepository.Branches
                where branch.FriendlyName == VersionResolver.BuildBranchName
                select branch).SingleOrDefault();

            if (buildBranch == null)
            {
                Log($"Dependency {dependency}: fixed versioning: '{VersionResolver.BuildBranchName}' branch not found => creating it at Commit = '{dependency.Commit}'...");
                otherRepository.CreateBranch(VersionResolver.BuildBranchName, dependency.Commit);
            }
            else
            {
                Log($"Dependency {dependency}: fixed versioning: '{VersionResolver.BuildBranchName}' branch found => checking it out and hard resetting it to Commit = '{dependency.Commit}'...");
                otherRepository.Checkout(buildBranch, new CheckoutOptions() { CheckoutModifiers = CheckoutModifiers.Force });
                otherRepository.Reset(ResetMode.Hard, dependencyCommit);
            }
        }
开发者ID:Bhaal22,项目名称:Msbuild.GitCloneTask,代码行数:23,代码来源:GitCloneTask.cs

示例12: CreateBranch

 public Branch CreateBranch(string branch, string baseBranchName)
 {
     using (var repo = new Repository(_settings.Workspace))
     {
         var baseBranch = repo.Lookup<Commit>(baseBranchName);
         return repo.CreateBranch(branch, baseBranch);
     }
 }
开发者ID:ericcastoldi,项目名称:Stag,代码行数:8,代码来源:Git.cs

示例13: Commit_succeeds_if_two_transactions_created_the_same_branch_pointing_to_the_same_commit

        public void Commit_succeeds_if_two_transactions_created_the_same_branch_pointing_to_the_same_commit()
        {
            const string branchName = "newBranch";
            
            var transaction1 = CreateTransaction();
            var transaction2 = CreateTransaction();

            transaction1.Begin();
            transaction2.Begin();

            // transaction 1: create branch
            using (var localRepository1 = new Repository(transaction1.LocalPath))
            {
                localRepository1.CreateBranch(branchName, localRepository1.Commits.Single());
            }

            // transaction 2: create branch
            using (var localRepository2 = new Repository(transaction2.LocalPath))
            {
                localRepository2.CreateBranch(branchName, localRepository2.Commits.Single());
            }

            // commit both transactions
            transaction1.Commit();
            transaction2.Commit();

            Assert.True(m_RemoteRepository.Branches.Any(x => x.FriendlyName == branchName));
        }
开发者ID:ap0llo,项目名称:SyncTool,代码行数:28,代码来源:AbstractGitTransactionTest.cs

示例14: Commit_fails_to_create_a_new_branch_if_the_same_branch_was_created_by_another_transaction

        public void Commit_fails_to_create_a_new_branch_if_the_same_branch_was_created_by_another_transaction()
        {
            const string branchName = "newBranch";
            
            var transaction1 = CreateTransaction();
            var transaction2 = CreateTransaction();

            transaction1.Begin();
            transaction2.Begin();

            using (var localRepository1 = new Repository(transaction1.LocalPath))
            {
                localRepository1.CreateBranch(branchName, localRepository1.Commits.Single());
            }

            AddFile(transaction1, branchName, "file1");

            using (var localRepository2 = new Repository(transaction2.LocalPath))
            {
                localRepository2.CreateBranch(branchName, localRepository2.Commits.Single());
            }

            transaction1.Commit();
            Assert.Throws<TransactionFailedException>(() => transaction2.Commit());
        }
开发者ID:ap0llo,项目名称:SyncTool,代码行数:25,代码来源:AbstractGitTransactionTest.cs

示例15: Commit_pushes_newly_created_branches

        public void Commit_pushes_newly_created_branches()
        {
            var branchName = "newBranch";

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

            using (var repository = new Repository(transaction.LocalPath))
            {
                repository.CreateBranch(branchName, repository.Commits.Single());
            }

            AddFile(transaction, branchName, "file1");
            
            transaction.Commit();

            Assert.True(m_RemoteRepository.Branches.Any(x => x.FriendlyName == branchName));
            Assert.Equal(2, m_RemoteRepository.GetAllCommits().Count());
        }
开发者ID:ap0llo,项目名称:SyncTool,代码行数:19,代码来源:AbstractGitTransactionTest.cs


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