예제 #1
0
파일: git_tests.py 프로젝트: jhford/uplift
    def test_get_rev(self):
        repo_contents = [
            {'A': 1},
            {'A': 2},
            {'A': 3}
        ]
        commits = self.create_repo(repo_contents)

        self.assertEqual(commits[-1], subject.get_rev(self.scratch))
        # Remember, the '2' needs to be a string because the tag is a string
        self.assertEqual(commits[2], subject.get_rev(self.scratch, '2'))
예제 #2
0
파일: git_tests.py 프로젝트: jhford/uplift
 def test_determine_cherry_pick_master_number(self):
     repo_contents = [
         {'A': 1},
         {'A': 2},
         {'A': 3}
     ]
     branch_contents = [
         {'A': 1},
         {'A': 2}
     ]
     commits = self.create_repo(repo_contents)
     subject.git_op(['checkout', '-t', 'master', '-b', 'newbranch'], self.scratch)
     branch_commits = self.create_commits(branch_contents)
     subject.git_op(['checkout', 'master'], self.scratch)
     subject.git_op(['merge', 'newbranch', '--no-ff'], self.scratch)
     merge_commit = subject.get_rev(self.scratch)
     #raise Exception((merge_commit, self.scratch))
     self.assertEqual(
         '-m1', 
         subject.determine_cherry_pick_master_number(
             self.scratch, 
             merge_commit, 
             'master'
         )
     )
     self.assertEqual(
         None,
         subject.determine_cherry_pick_master_number(
             self.scratch,
             commits[2],
             'master'
         )
     )
예제 #3
0
파일: git_tests.py 프로젝트: jhford/uplift
 def test_merge_ff(self):
     contents = [{'A': '1'}]
     branch_contents = [{'A': '2'}]
     commits = self.create_repo(contents)
     subject.checkout(self.scratch, branch_name='newbranch')
     branch_commits = self.create_commits(branch_contents)
     subject.checkout(self.scratch, 'master')
     
     subject.merge(self.scratch, 'newbranch', ff_only=True)
     self.assertEqual(branch_commits[0], subject.get_rev(self.scratch, id='master'))
     self.assertEqual(1, len(subject.find_parents(self.scratch, 'master')))
예제 #4
0
파일: git_tests.py 프로젝트: jhford/uplift
 def test_cherry_pick_commit_is_merge_commit(self):
     contents = [{'A': '1', 'B': '2'}]
     commits = self.create_repo(contents)
     subject.checkout(self.scratch, branch_name='newbranch', tracking='master')
     subject.checkout(self.scratch, branch_name='pr_branch', tracking='master')
     pr_contents = [{'C': '3'}]
     pr_commits = self.create_commits(pr_contents)
     subject.checkout(self.scratch, 'master')
     subject.merge(self.scratch, 'pr_branch', no_ff=True)
     merge_commit = subject.get_rev(self.scratch)
     self.assertEqual(sorted([pr_commits[0], commits[-1]]), sorted(subject.find_parents(self.scratch, merge_commit)))
     branch_commit = subject.cherry_pick(self.scratch, merge_commit, 'newbranch')
     self.assertTrue(subject.commit_on_branch(self.scratch, branch_commit, 'newbranch'))
     self.assertFalse(subject.commit_on_branch(self.scratch, branch_commit, 'master'))
예제 #5
0
파일: git_tests.py 프로젝트: jhford/uplift
    def test_dry_run_clean(self):
        contents = [{'A': x} for x in range(5)] 
        common_commits = self.create_repos(2, contents)
        new_content = [{'A': x} for x in range(5, 10)]
        new_commits = self.create_commits(1, new_content)
        
        expected = {
            'url': os.path.abspath(self.scratch[0]),
            'branches':{
                'master': (common_commits[-1], new_commits[-1])
            }
        }
        actual = subject.push(self.scratch[1], 'origin', ['master'])
        self.assertEqual(expected['url'], actual['url'])
        self.assertEqual(expected['branches'], actual['branches'])
        self.assertEqual(expected, actual)

        with self.assertRaises(subject.GitError):
            # We chop the commit id down to 7 chars because this
            # forces git to not short-circuit and just echo the
            # full length id it's given.  This also seperates
            # the concern of the git repo having the commit object
            # from a branch having the commit object
            subject.get_rev(self.scratch[0], new_commits[0][:7])
예제 #6
0
파일: git_tests.py 프로젝트: jhford/uplift
    def test_for_real_clean(self):
        contents = [{'A': x} for x in range(5)] 
        common_commits = self.create_repos(2, contents)
        new_content = [{'A': x} for x in range(5, 10)]
        new_commits = self.create_commits(1, new_content)
        subject.checkout(self.scratch[0], branch_name='notmaster')
        
        expected = {
            'url': os.path.abspath(self.scratch[0]),
            'branches':{
                'master': (common_commits[-1], new_commits[-1])
            }
        }
        actual = subject.push(self.scratch[1], 'origin', ['master'], dry_run=False)

        self.assertEqual(new_commits[0],
            subject.get_rev(self.scratch[0], new_commits[0][:7]))