Exemple #1
0
 def read_issue_by_number(self, number: int) -> Issue:
     repo: Repo = GitCmd(self.state_handler, self.options.debug).get_repo()
     # repo: Repo = Repo(owner='flexiooss', repo='flexio-flow-punching-ball')
     resp: Response = Github(
         self.config_handler).with_repo(repo).read_issue(
             IssueGithub().with_number(number))
     return IssueGithub.from_api_dict(resp.json())
Exemple #2
0
 def __init__(self, state_handler: StateHandler,
              config_handler: ConfigHandler):
     self.__state_handler: StateHandler = state_handler
     self.__config_handler: ConfigHandler = config_handler
     self.__branch: str = None
     self.__git: GitCmd = GitCmd(
         self.__state_handler).with_config_handler(config_handler)
    def setUp(self):
        print('setUp')
        self.state_handler = TestGitFlowHelper.init_repo(INIT_VERSION)

        self.git: GitCmd = GitCmd(state_handler=self.state_handler)
        self.git_flow: GitFlowCmd = GitFlowCmd(
            state_handler=self.state_handler)
Exemple #4
0
    def setUp(self):
        # self.state_handler = TestGitFlowHelper.init_repo(INIT_VERSION)
        # # self.state_handler: StateHandler = StateHandler(TestGitFlowHelper.DIR_PATH_TEST).load_file_config()
        self.state_handler: StateHandler = StateHandler(Path('/tmp/test'))

        self.git: GitCmd = GitCmd(state_handler=self.state_handler)
        self.git_flow: GitFlowCmd = GitFlowCmd(
            state_handler=self.state_handler)
Exemple #5
0
 def comment(self, issue: IssueGithub, text: str) -> Issue:
     repo: Repo = GitCmd(self.state_handler,
                         self.options.debug).with_config_handler(
                             self.config_handler).get_repo()
     resp: Response = Github(
         self.config_handler).with_repo(repo).create_comment(issue=issue,
                                                             body=text)
     return IssueGithub.from_api_dict(resp.json())
 def clean_remote_repo(cls, version: Version = Version(0, 0, 0)):
     git: GitCmd = GitCmd(
         state_handler=StateHandler(TestGitFlowHelper.DIR_PATH_TEST))
     git.checkout(Branches.MASTER).reset_to_tag(cls.TAG_INIT) \
         .push_force() \
         .delete_remote_branch_from_name(Branches.DEVELOP.value) \
         .delete_tag(str(version), remote=True) \
         .delete_tag('-'.join([str(version.next_minor()), Level.DEV.value]), remote=True)
     Log.info('clean remote repo : ' + str(version))
Exemple #7
0
 def attach_or_create(self, default_issue: Optional[IssueDefault],
                      options: Optional[Dict[str, str]]) -> Issue:
     repo: Repo = GitCmd(self.state_handler,
                         self.options.debug).with_config_handler(
                             self.config_handler).get_repo()
     return AttachOrCreate(config_handler=self.config_handler,
                           repo=repo,
                           default_issue=default_issue,
                           options=options).process()
Exemple #8
0
 def __init__(self, state_handler: StateHandler,
              config_handler: ConfigHandler, issue: Optional[Type[Issue]],
              topics: Optional[List[Topic]]):
     self.__state_handler: StateHandler = state_handler
     self.__config_handler: ConfigHandler = config_handler
     self.__issue: Optional[Type[Issue]] = issue
     self.__topics: Optional[List[Topic]] = topics
     self.__git: GitCmd = GitCmd(
         self.__state_handler).with_config_handler(config_handler)
     self.__gitflow: GitFlowCmd = GitFlowCmd(self.__state_handler,
                                             config_handler)
Exemple #9
0
 def has_repo(self) -> bool:
     has_repo: bool = False
     try:
         repo: Repo = GitCmd(self.state_handler,
                             self.options.debug).with_config_handler(
                                 self.config_handler).get_repo()
         has_repo = True
     except ValueError as e:
         if self.options.debug:
             print(e)
         Log.info('GithubIssuer have not repo')
     finally:
         return has_repo
Exemple #10
0
 def __init__(self, state_handler: StateHandler,
              config_handler: ConfigHandler, issue: Optional[Type[Issue]],
              topics: Optional[List[Topic]], keep_branch: bool,
              close_issue: bool):
     self.__state_handler: StateHandler = state_handler
     self.__config_handler: ConfigHandler = config_handler
     self.__issue: Optional[Type[Issue]] = issue
     self.__topics: Optional[List[Topic]] = topics
     self.__git: GitCmd = GitCmd(self.__state_handler).with_config_handler(
         config_handler=config_handler)
     self.__gitflow: GitFlowCmd = GitFlowCmd(self.__state_handler,
                                             config_handler)
     self.__keep_branch: bool = keep_branch
     self.__close_issue: bool = close_issue
     self.__current_branch_name: str = self.__git.get_current_branch_name()
    def setUp(self):
        # TestGitFlowHelper.clean_workdir()
        # TestGitFlowHelper.init_repo(INIT_VERSION)
        # GitCmd(state_handler=StateHandler(TestGitFlowHelper.DIR_PATH_TEST)).delete_branch_from_name(
        #     'hotfix/0.0.1-dev',
        #     remote=True
        # ).delete_tag('0.0.1', remote=True)

        # TestGitFlowHelper.clean_remote_repo()
        # TestGitFlowHelper.clean_workdir()

        self.state_handler = TestGitFlowHelper.init_repo(INIT_VERSION)

        self.git: GitCmd = GitCmd(state_handler=self.state_handler)
        self.git_flow: GitFlowCmd = GitFlowCmd(
            state_handler=self.state_handler)
Exemple #12
0
 def __init__(self, state_handler: StateHandler,
              config_handler: ConfigHandler, issue: Optional[Type[Issue]],
              topics: Optional[List[Topic]], keep_branch: bool,
              close_issue: bool):
     self.__state_handler: StateHandler = state_handler
     self.__config_handler: ConfigHandler = config_handler
     self.__issue: Optional[Type[Issue]] = issue
     self.__topics: Optional[List[Topic]] = topics
     self.__git: GitCmd = GitCmd(self.__state_handler)
     self.__gitflow: GitFlowCmd = GitFlowCmd(self.__state_handler,
                                             config_handler)
     self.__keep_branch: bool = keep_branch
     self.__close_issue: bool = close_issue
     self.__name: str = self.__git.get_branch_name_from_git(
         config_handler.release())
     self.__version_check: str = self.__state_handler.version_as_str()
 def mount_workdir_and_clone(cls):
     cls.DIR_PATH_TEST.mkdir()
     git: GitCmd = GitCmd(
         state_handler=StateHandler(TestGitFlowHelper.DIR_PATH_TEST))
     git.clone(cls.REPO_URL)
Exemple #14
0
import unittest
from pathlib import Path

from FlexioFlow.StateHandler import StateHandler
from VersionControl.Git.Branches.GitFlowCmd import GitFlowCmd
from VersionControl.Git.GitCmd import GitCmd

from Branches.Branches import Branches
from VersionControlProvider.Github.Repo import Repo
from tests.VersionControl.GitFlow.TestGitFlowHelper import TestGitFlowHelper

tag_test: str = 'tag_test'
git: GitCmd = GitCmd(
    state_handler=StateHandler(TestGitFlowHelper.DIR_PATH_TEST))

INIT_VERSION: str = '0.0.0'


class TestGitCmd(unittest.TestCase):
    def setUp(self):
        # self.state_handler = TestGitFlowHelper.init_repo(INIT_VERSION)
        # # self.state_handler: StateHandler = StateHandler(TestGitFlowHelper.DIR_PATH_TEST).load_file_config()
        self.state_handler: StateHandler = StateHandler(Path('/tmp/test'))

        self.git: GitCmd = GitCmd(state_handler=self.state_handler)
        self.git_flow: GitFlowCmd = GitFlowCmd(
            state_handler=self.state_handler)

    def test_has_branch(self):
        has_branch: bool = self.git.local_branch_exists('hotfix')
        self.assertTrue(has_branch)
Exemple #15
0
 def stash_start(self):
     GitCmd(self.state_handler).stash()
 def __init__(self, state_handler: StateHandler):
     super().__init__(state_handler)
     self.__git: GitCmd = GitCmd(self.state_handler)
Exemple #17
0
    def create(self, default_issue: Optional[IssueDefault]) -> Issue:
        repo: Repo = GitCmd(self.state_handler,
                            self.options.debug).with_config_handler(
                                self.config_handler).get_repo()

        return Create(self.config_handler, repo, default_issue).process()
Exemple #18
0
 def stash_end(self):
     GitCmd(self.state_handler).stash_pop()
Exemple #19
0
 def __init__(self, state_handler: StateHandler):
     self.__state_handler: StateHandler = state_handler
     self.__git: GitCmd = GitCmd(self.__state_handler)
Exemple #20
0
 def is_current_branch_develop(self) -> bool:
     return GitCmd(self.state_handler).get_current_branch_name() == self.config_handler.develop()