Beispiel #1
0
 def get_remote_branch(self,
                       branch: str,
                       remote: Optional[str] = None,
                       url: Optional[str] = None,
                       online: bool = False) -> Optional[RemoteBranch]:
     remote = ORIGIN if remote is None else remote
     from pygoodle.git.model.factory import GitFactory
     if online or url is not None:
         return GitFactory.get_remote_branch_online(self.path,
                                                    branch=branch,
                                                    remote=remote,
                                                    url=url)
     return GitFactory.get_remote_branch_offline(self.path,
                                                 branch=branch,
                                                 remote=remote)
Beispiel #2
0
 def get_remote_tag(self,
                    tag: str,
                    remote: Optional[str] = None,
                    url: Optional[str] = None) -> Optional[RemoteTag]:
     remote = ORIGIN if remote is None else remote
     from pygoodle.git.model.factory import GitFactory
     return GitFactory.get_remote_tag(self.path, tag, remote, url=url)
Beispiel #3
0
 def delete(self) -> None:
     from pygoodle.git.model.factory import GitFactory
     if not GitFactory.has_remote_branch_online(self.path, self.name,
                                                self.remote.name):
         CONSOLE.stdout(
             f" - Remote branch {Format.Git.ref(self.name)} doesn't exist")
         return
     CONSOLE.stdout(f' - Delete remote branch {Format.Git.ref(self.name)}')
     GitOnline.delete_remote_branch(self.path,
                                    branch=self.name,
                                    remote=self.remote.name,
                                    force=True)
Beispiel #4
0
 def get_remote(self,
                remote: Optional[str] = None,
                fetch_url: Optional[str] = None,
                push_url: Optional[str] = None) -> Optional[Remote]:
     from pygoodle.git.model.factory import GitFactory
     remotes = GitFactory.get_remotes(self.path)
     if remote is not None:
         remotes = [r for r in remotes if r.name == remote]
     if fetch_url is not None:
         remotes = [r for r in remotes if r.fetch_url == fetch_url]
     if push_url is not None:
         remotes = [r for r in remotes if r.push_url == push_url]
     return remotes[0] if remotes else None
Beispiel #5
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)
Beispiel #6
0
 def exists(self) -> bool:
     from pygoodle.git.model.factory import GitFactory
     return GitFactory.has_local_branch(self.path, self.name)
Beispiel #7
0
 def remote(self, name: str) -> Optional[Remote]:
     from pygoodle.git.model.factory import GitFactory
     return GitFactory.get_remote(self.path, name)
Beispiel #8
0
 def is_tracking_branch(self) -> bool:
     from pygoodle.git.model.factory import GitFactory
     branches = GitFactory.get_tracking_branches(self.path)
     return any([branch.name == self.name for branch in branches])
Beispiel #9
0
 def get_all_branches(self, online: bool = False) -> 'AllBranches':
     from pygoodle.git.model.factory import GitFactory
     return GitFactory.get_all_branches(self.path, online=online)
Beispiel #10
0
 def get_diff(self) -> 'Diff':
     from pygoodle.git.model.factory import GitFactory
     return GitFactory.get_diff(self.path)
Beispiel #11
0
 def exists(self) -> bool:
     from pygoodle.git.model.factory import GitFactory
     return GitFactory.has_remote_tag(self.path, self.name,
                                      self.remote.name)
Beispiel #12
0
 def exists_online(self, url: Optional[str] = None) -> bool:
     from pygoodle.git.model.factory import GitFactory
     return GitFactory.has_remote_branch_online(self.path,
                                                branch=self.name,
                                                remote=self.remote.name,
                                                url=url)
Beispiel #13
0
 def get_local_tags(self) -> List[LocalTag]:
     from pygoodle.git.model.factory import GitFactory
     return GitFactory.get_local_tags(self.path)
Beispiel #14
0
 def get_local_tag(self, tag: str) -> Optional[LocalTag]:
     from pygoodle.git.model.factory import GitFactory
     return GitFactory.get_local_tag(self.path, tag)
Beispiel #15
0
 def get_local_branches(self) -> List[LocalBranch]:
     from pygoodle.git.model.factory import GitFactory
     return GitFactory.get_local_branches(self.path)
Beispiel #16
0
 def get_local_branch(self, branch: str) -> Optional[LocalBranch]:
     from pygoodle.git.model.factory import GitFactory
     return GitFactory.get_local_branch(self.path, branch)
Beispiel #17
0
 def get_submodule(self, submodule_path: Path) -> Optional['Submodule']:
     from pygoodle.git.model.factory import GitFactory
     return GitFactory.get_submodule(self.path, submodule_path)
Beispiel #18
0
 def is_tracking_branch(self) -> bool:
     from pygoodle.git.model.factory import GitFactory
     return GitFactory.has_tracking_branch(self.path, self.name)
Beispiel #19
0
 def get_submodules(self) -> List['Submodule']:
     from pygoodle.git.model.factory import GitFactory
     return GitFactory.get_submodules(self.path)
Beispiel #20
0
 def get_tracking_branches(self) -> List[TrackingBranch]:
     from pygoodle.git.model.factory import GitFactory
     return GitFactory.get_tracking_branches(self.path)
Beispiel #21
0
 def get_tracking_branch(
         self,
         branch: str,
         remote: Optional[str] = None) -> Optional[TrackingBranch]:
     from pygoodle.git.model.factory import GitFactory
     return GitFactory.get_tracking_branch(self.path, branch, remote=remote)
Beispiel #22
0
 def branches(self, url: Optional[str] = None, online: bool = False) -> List[RemoteBranch]:
     from pygoodle.git.model.factory import GitFactory
     if online or url is not None:
         return GitFactory.get_remote_branches_online(self.path, remote=self.name, url=url)
     return GitFactory.get_remote_branches_offline(self.path, self.name)
Beispiel #23
0
 def get_remote_branches(self, online: bool = False) -> List[RemoteBranch]:
     from pygoodle.git.model.factory import GitFactory
     return GitFactory.get_all_remote_branches(self.path, online=online)
Beispiel #24
0
 def exists_online(self, url: str) -> bool:
     from pygoodle.git.model.factory import GitFactory
     return GitFactory.has_remote_tag(self.path,
                                      tag=self.name,
                                      remote=self.remote.name,
                                      url=url)
Beispiel #25
0
 def get_remotes(self) -> List[Remote]:
     from pygoodle.git.model.factory import GitFactory
     return GitFactory.get_remotes(self.path)