def test_delete_all_old_local_branches(self):
        manager = BranchManager(self.__mConfig)

        self.assertTrue(len(manager.getLocalBranches()) != 1)

        branchesToDelete = manager.getLocalBranches()
        manager.deleteAllOldBranches(branchesToDelete)

        # Master should be the only branch remaining
        self.assertTrue(len(manager.getLocalBranches()) == 1)
Esempio n. 2
0
  def test_delete_all_old_local_branches(self):
    manager = BranchManager(self.__mConfig)

    self.assertTrue(len(manager.getLocalBranches()) != 1)

    branchesToDelete = manager.getLocalBranches()
    manager.deleteAllOldBranches(branchesToDelete)

    # Master should be the only branch remaining
    self.assertTrue(len(manager.getLocalBranches()) == 1)
    def test_delete_all_old_remote_branches(self):
        config = BranchHealthConfig(self.__mConfig.getRepoPath(), 'origin', 1)
        manager = BranchManager(config)

        self.assertTrue(len(manager.getLocalBranches()) != 1)
        self.assertTrue(len(config.getRepo().remotes.origin.refs) != 2)

        branchMap = manager.getBranchMap()
        branchesToDelete = [x for x in branchMap]
        manager.deleteAllOldBranches(branchesToDelete)

        # Master should be the only branch remaining
        self.assertTrue(len(manager.getLocalBranches()) == 1)

        # Master and HEAD should be remaining
        self.assertTrue(len(config.getRepo().remotes.origin.refs) == 2)
    def test_mark_branch_health(self):
        options = self.__mParent.getConfig()
        manager = BranchManager(options)
        branches = manager.getLocalBranches()
        for someBranch in branches:
            someBranch.markHealth()
            self.assertEquals(Branch.OLD, someBranch.getHealth())

        # Now, create a new branch so we can test if it returns the value
        # Branch.HEALTHY
        repo = options.getRepo()
        repo.create_head('aNewBranch')
        repo.heads.aNewBranch.checkout()

        # Create a new file so we have a new commit
        fh = open(
            os.path.join(self.__mParent.getTempDir(), "testrepo/myNewFile"),
            "w")
        fh.write("TEST123")
        fh.close()

        index = repo.index
        index.add(['myNewFile'])
        index.commit("A new commit")

        newBranch = Branch('refs/heads/aNewBranch', options)
        newBranch.markHealth()
        self.assertEquals(Branch.HEALTHY, newBranch.getHealth())
Esempio n. 5
0
  def test_mark_branch_health(self):
    options = self.__mParent.getConfig()
    manager = BranchManager(options)
    branches = manager.getLocalBranches()
    for someBranch in branches:
      someBranch.markHealth()
      self.assertEquals(Branch.OLD, someBranch.getHealth())

    # Now, create a new branch so we can test if it returns the value
    # Branch.HEALTHY
    repo = options.getRepo()
    repo.create_head('aNewBranch')
    repo.heads.aNewBranch.checkout()

    # Create a new file so we have a new commit
    fh = open(os.path.join(self.__mParent.getTempDir(), "testrepo/myNewFile"), "w")
    fh.write("TEST123")
    fh.close()

    index = repo.index
    index.add(['myNewFile'])
    index.commit("A new commit")

    newBranch = Branch('refs/heads/aNewBranch', options)
    newBranch.markHealth()
    self.assertEquals(Branch.HEALTHY, newBranch.getHealth())
    def test_get_local_branches(self):
        manager = BranchManager(self.__mConfig)
        branches = manager.getLocalBranches()
        branchNames = manager.getLocalBranchNames()
        names = []
        for branch in branches:
            names.append(branch.getName())

        self.assertEquals(branchNames, names)
 def test_branch_sorting(self):
     options = self.__mParent.getConfig()
     manager = BranchManager(options)
     branches = [
         x.getName()
         for x in sorted(manager.getLocalBranches(), branchDateComparator)
     ]
     expectedBranches = ['bug-14', 'bug-44', 'bug-27', 'bug-143', 'master']
     self.assertEqual(expectedBranches, branches)
Esempio n. 8
0
  def test_get_local_branches(self):
    manager = BranchManager(self.__mConfig)
    branches = manager.getLocalBranches()
    branchNames = manager.getLocalBranchNames()
    names = []
    for branch in branches:
      names.append(branch.getName())

    self.assertEquals(branchNames, names)
Esempio n. 9
0
  def test_delete_all_old_remote_branches(self):
    config = BranchHealthConfig(self.__mConfig.getRepoPath(),
                                'origin',
                                1)
    manager = BranchManager(config)

    self.assertTrue(len(manager.getLocalBranches()) != 1)
    self.assertTrue(len(config.getRepo().remotes.origin.refs) != 2)

    branchMap = manager.getBranchMap()
    branchesToDelete = [x for x in branchMap]
    manager.deleteAllOldBranches(branchesToDelete)

    # Master should be the only branch remaining
    self.assertTrue(len(manager.getLocalBranches()) == 1)

    # Master and HEAD should be remaining
    self.assertTrue(len(config.getRepo().remotes.origin.refs) == 2)
Esempio n. 10
0
 def test_branch_sorting(self):
   options = self.__mParent.getConfig()
   manager = BranchManager(options)
   branches = [x.getName() for x in sorted(manager.getLocalBranches(), branchDateComparator)]
   expectedBranches = ['bug-14', 'bug-44', 'bug-27', 'bug-143', 'master']
   self.assertEqual(expectedBranches, branches)