예제 #1
0
 def create(self,
            branch: Optional[str] = None,
            remote: Optional[str] = None) -> None:
     from pygoodle.git.model.factory import GitFactory
     if GitFactory.has_remote_branch_online(self.path, self.name,
                                            self.remote.name):
         CONSOLE.stdout(
             f' - Remote branch {Format.Git.ref(self.name)} already exists')
         return
     CONSOLE.stdout(f' - Create remote branch {Format.Git.ref(self.name)}')
     branch = self.name if branch is None else branch
     from pygoodle.git.model.branch.local_branch import LocalBranch
     local_branch = LocalBranch(self.path, branch)
     GitOnline.fetch(self.path, prune=True)
     has_existing_branch = local_branch.exists
     if not has_existing_branch:
         local_branch.create(branch=branch, remote=remote)
     local_branch.push(remote=self.remote.name, branch=self.name)
     if not has_existing_branch:
         GitOffline.delete_local_branch(self.path, branch)
     GitOnline.fetch(self.path, prune=True)
예제 #2
0
 def delete(self, force: bool = False) -> None:
     if not self.exists:
         CONSOLE.stdout(f" - Local branch {Format.Git.ref(self.short_ref)} doesn't exist")
         return
     CONSOLE.stdout(f' - Delete local branch {Format.Git.ref(self.short_ref)}')
     GitOffline.delete_local_branch(self.path, self.name, force=force)