Beispiel #1
0
 def herd(self):
     """Clone project or update latest from upstream"""
     self._print_status()
     if not os.path.isdir(os.path.join(self.full_path(), '.git')):
         git_clone_url_at_path(self.url, self.full_path(), self.ref, self.remote_name)
     else:
         ref_type = git_ref_type(self.ref)
         if ref_type is 'branch':
             git_create_remote(self.full_path(), self.remote_name, self.url)
             git_fetch(self.full_path())
             git_checkout_ref(self.full_path(), self.ref, self.remote_name)
             branch = git_truncate_ref(self.ref)
             git_pull_remote_branch(self.full_path(), self.remote_name, branch)
         elif ref_type is 'tag' or ref_type is 'sha':
             git_create_remote(self.full_path(), self.remote_name, self.url)
             git_fetch(self.full_path())
             git_checkout_ref(self.full_path(), self.ref, self.remote_name)
         else:
             print('Unknown ref ' + self.ref)
 def test_git_truncate_ref_sha(self):
     """Test git_truncate_ref() function for sha ref"""
     self.assertEqual(git_truncate_ref(self.sha_ref), self.sha_ref)
 def test_git_truncate_ref_tag(self):
     """Test git_truncate_ref() function for tag ref"""
     self.assertEqual(git_truncate_ref(self.tag_ref), 'v1.0')
 def test_git_truncate_ref_branch(self):
     """Test git_truncate_ref() function for branch ref"""
     self.assertEqual(git_truncate_ref(self.branch_ref), 'master')