Пример #1
0
    def is_local_remote_equal(self, branch: str) -> bool:
        if not self.branch_exists(branch):
            raise BranchNotExist(branch)

        local_branch: str = self.local_branch_name(branch)
        remote_branch: str = self.remote_branch_name(branch)
        compare_refs: int = self.compare_refs(local_branch, remote_branch)

        if compare_refs > 0:
            print("Branches '{local_branch!s}' and '{remote_branch!s}' have diverged.".format(local_branch=local_branch,
                                                                                              remote_branch=remote_branch))
            if compare_refs == 1:
                print("And branch '{local_branch!s}' may be fast-forwarded.".format(local_branch=local_branch))
            elif compare_refs == 2:
                print("And local branch '{local_branch!s}' is ahead of '{remote_branch!s}'.".format(
                    local_branch=local_branch,
                    remote_branch=remote_branch
                ))
            else:
                Log.warning("Branches need merging first.")
            return False
        return True
Пример #2
0
    def process(self):

        if self.action is TopicActions.READ:
            topic_builder: TopicBuilder = TopicBuilder(self.version_control,
                                                       self.state_handler,
                                                       self.config_handler,
                                                       None, self.options)

            topics: Optional[List[
                AbstractTopic]] = topic_builder.find_topic_from_branch_name(
                ).topics()

            if topics is not None and len(topics) > 0:
                for topic in topics:
                    Log.info('waiting... from flexio...')

                    read_topic: Optional[
                        AbstractTopic] = topic_builder.topicer(
                        ).read_topic_by_number(int(topic.number))
                    if read_topic is not None:
                        CommonTopic.print_resume_topic(read_topic)
            else:
                Log.warning('No Topic found')
Пример #3
0
 def ensure_master_branch(self) -> GitFlowCmd:
     Log.info('Ensure have Master branch : ' +
              self.__config_handler.master())
     if not self.__git.local_branch_exists(self.__config_handler.master()):
         if not self.__git.remote_branch_exists(
                 self.__config_handler.master()):
             Log.warning(self.__config_handler.master() + ' not exists')
             create: str = input('Create ' +
                                 self.__config_handler.master() +
                                 ' from current branch ?  y/' +
                                 Fg.SUCCESS.value + 'n' + Fg.RESET.value +
                                 ' : ')
             if create == 'y':
                 self.__git.create_branch_from(
                     self.__config_handler.master(),
                     self.__git.get_current_branch_name()
                 ).try_to_set_upstream().try_to_push()
                 self.ensure_master_branch()
             else:
                 raise BranchNotExist(self.__config_handler.master())
         else:
             Log.error('Remote branch : ' + self.__config_handler.master() +
                       ' already exists, pull before')
     return self
Пример #4
0
 def get_poom_ci_produces(self) -> List[Module]:
     Log.warning('Not implemented yet')
Пример #5
0
 def get_poom_ci_dependencies(self) -> List[Module]:
     Log.warning('Not implemented yet')
Пример #6
0
 def ensure_head(self) -> GitFlowCmd:
     if not self.__git.has_head():
         Log.warning('The repository does not have a HEAD yet')
         self.__git.init_head().commit('Initial commit', ['--allow-empty'])
         Log.info('Initial commit')
     return self