示例#1
0
    def test_load_target_exception(self):
        config_yaml = """
/product_attribute:
    remotes:
        oca: https://github.com/OCA/product-attribute.git
    merges:
        - oca 8.0
    target: oca 8.0 extra_arg
"""
        with self.assertRaises(ConfigException) as ex:
            config.get_repos(self._parse_config(config_yaml))
        self.assertEquals(
            ex.exception.args[0],
            '/product_attribute: Target must be formatted as '
            '"[remote_name] branch_name"')

        config_yaml = """
/product_attribute:
    remotes:
        oca: https://github.com/OCA/product-attribute.git
    merges:
        - oca 8.0
    target: oba aggregated_branch
"""
        with self.assertRaises(ConfigException) as ex:
            config.get_repos(self._parse_config(config_yaml))
        self.assertEquals(
            ex.exception.args[0],
            '/product_attribute: Target remote oba not defined in remotes.')
示例#2
0
    def test_target_defaults(self):
        config_yaml = """
/product_attribute:
    remotes:
        oca: https://github.com/OCA/product-attribute.git
    merges:
        - oca 8.0
    target: 8.0
"""
        repos = config.get_repos(self._parse_config(config_yaml))
        self.assertDictEqual(repos[0]["target"], {
            "branch": "8.0",
            "remote": None
        })

        config_yaml = """
/product_attribute:
    remotes:
        oca: https://github.com/OCA/product-attribute.git
    merges:
        - oca 8.0
"""
        repos = config.get_repos(self._parse_config(config_yaml))
        self.assertDictEqual(repos[0]["target"], {
            "branch": "_git_aggregated",
            "remote": None
        })
示例#3
0
    def test_load_shell_command_after(self):
        """Shell command after are alway parser as a list
        """
        config_yaml = """
/product_attribute:
    remotes:
        oca: https://github.com/OCA/product-attribute.git
        acsone: git+ssh://[email protected]/acsone/product-attribute.git
    merges:
        - oca 8.0
    target: acsone aggregated_branch_name
    shell_command_after: ls
        """
        repos = config.get_repos(self._parse_config(config_yaml))
        self.assertEquals(repos[0]['shell_command_after'], ['ls'])
        config_yaml = """
/product_attribute:
    remotes:
        oca: https://github.com/OCA/product-attribute.git
        acsone: git+ssh://[email protected]/acsone/product-attribute.git
    merges:
        - oca 8.0
    target: acsone aggregated_branch_name
    shell_command_after:
        - ls
        - echo
        """
        repos = config.get_repos(self._parse_config(config_yaml))
        self.assertEquals(repos[0]['shell_command_after'], ['ls', 'echo'])
示例#4
0
    def test_load_shell_command_after(self):
        """Shell command after are alway parser as a list
        """
        config_yaml = """
/product_attribute:
    remotes:
        oca: https://github.com/OCA/product-attribute.git
        acsone: git+ssh://[email protected]/acsone/product-attribute.git
    merges:
        - oca 8.0
    target: acsone aggregated_branch_name
    shell_command_after: ls
        """
        repos = config.get_repos(self._parse_config(config_yaml))
        self.assertEquals(repos[0]['shell_command_after'], ['ls'])
        config_yaml = """
/product_attribute:
    remotes:
        oca: https://github.com/OCA/product-attribute.git
        acsone: git+ssh://[email protected]/acsone/product-attribute.git
    merges:
        - oca 8.0
    target: acsone aggregated_branch_name
    shell_command_after:
        - ls
        - echo
        """
        repos = config.get_repos(self._parse_config(config_yaml))
        self.assertEquals(repos[0]['shell_command_after'], ['ls', 'echo'])
示例#5
0
 def test_load_defaults(self):
     config_yaml = dedent("""
         /web:
             defaults:
                 depth: 1
             remotes:
                 oca: https://github.com/OCA/web.git
                 acsone: git+ssh://[email protected]/acsone/web.git
             merges:
                 -
                     remote: oca
                     ref: 8.0
                     depth: 1000
                 - oca refs/pull/105/head
                 -
                     remote: oca
                     ref: refs/pull/106/head
             target: acsone aggregated_branch_name
     """)
     repos = config.get_repos(self._parse_config(config_yaml))
     self.assertEquals(len(repos), 1)
     # remotes are configured as dict therefore the order is not preserved
     # when parsed
     remotes = repos[0]['remotes']
     repos[0]['remotes'] = []
     self.assertDictEqual(
         repos[0], {
             'cwd':
             '/web',
             'fetch_all':
             False,
             'defaults': {
                 'depth': 1
             },
             'merges': [{
                 'ref': '8.0',
                 'remote': 'oca',
                 'depth': 1000
             }, {
                 'ref': 'refs/pull/105/head',
                 'remote': 'oca'
             }, {
                 'ref': 'refs/pull/106/head',
                 'remote': 'oca'
             }],
             'remotes': [],
             'shell_command_after': [],
             'target': {
                 'branch': 'aggregated_branch_name',
                 'remote': 'acsone'
             }
         })
     assertfn = self.assertItemsEqual if PY2 else self.assertCountEqual
     assertfn(remotes, [{
         'name': 'oca',
         'url': 'https://github.com/OCA/web.git'
     }, {
         'name': 'acsone',
         'url': 'git+ssh://[email protected]/acsone/web.git'
     }])
示例#6
0
    def test_load_merges_exception(self):
        config_yaml = """
/product_attribute:
    remotes:
        oca: https://github.com/OCA/product-attribute.git
    target: oca aggregated_branch
"""
        with self.assertRaises(ConfigException) as ex:
            config.get_repos(self._parse_config(config_yaml))
        self.assertEquals(
            ex.exception.args[0],
            '/product_attribute: merges is not defined.')

        config_yaml = """
/product_attribute:
    remotes:
        oca: https://github.com/OCA/product-attribute.git
    merges:
        - oca
    target: oca aggregated_branch
"""
        with self.assertRaises(ConfigException) as ex:
            config.get_repos(self._parse_config(config_yaml))
        self.assertEquals(
            ex.exception.args[0],
            '/product_attribute: Merge must be formatted as '
            '"remote_name ref".')
        config_yaml = """
/product_attribute:
    remotes:
        oca: https://github.com/OCA/product-attribute.git
    merges:
    target: oca aggregated_branch
"""
        with self.assertRaises(ConfigException) as ex:
            config.get_repos(self._parse_config(config_yaml))
        self.assertEquals(
            ex.exception.args[0],
            '/product_attribute: You should at least define one merge.')

        config_yaml = """
/product_attribute:
    remotes:
        oca: https://github.com/OCA/product-attribute.git
    merges:
        - oba 8.0
    target: oca aggregated_branch
"""
        with self.assertRaises(ConfigException) as ex:
            config.get_repos(self._parse_config(config_yaml))
        self.assertEquals(
            ex.exception.args[0],
            '/product_attribute: Merge remote oba not defined in remotes.')
示例#7
0
    def test_load_merges_exception(self):
        config_yaml = """
/product_attribute:
    remotes:
        oca: https://github.com/OCA/product-attribute.git
    target: oca aggregated_branch
"""
        with self.assertRaises(ConfigException) as ex:
            config.get_repos(self._parse_config(config_yaml))
        self.assertEquals(ex.exception.args[0],
                          '/product_attribute: merges is not defined.')

        config_yaml = """
/product_attribute:
    remotes:
        oca: https://github.com/OCA/product-attribute.git
    merges:
        - oca
    target: oca aggregated_branch
"""
        with self.assertRaises(ConfigException) as ex:
            config.get_repos(self._parse_config(config_yaml))
        self.assertEquals(
            ex.exception.args[0],
            '/product_attribute: Merge must be formatted as '
            '"remote_name ref".')
        config_yaml = """
/product_attribute:
    remotes:
        oca: https://github.com/OCA/product-attribute.git
    merges:
    target: oca aggregated_branch
"""
        with self.assertRaises(ConfigException) as ex:
            config.get_repos(self._parse_config(config_yaml))
        self.assertEquals(
            ex.exception.args[0],
            '/product_attribute: You should at least define one merge.')

        config_yaml = """
/product_attribute:
    remotes:
        oca: https://github.com/OCA/product-attribute.git
    merges:
        - oba 8.0
    target: oca aggregated_branch
"""
        with self.assertRaises(ConfigException) as ex:
            config.get_repos(self._parse_config(config_yaml))
        self.assertEquals(
            ex.exception.args[0],
            '/product_attribute: Merge remote oba not defined in remotes.')
示例#8
0
 def test_fetch_all_true(self):
     config_yaml = """
         ./test:
             remotes:
                 oca: https://github.com/test/test.git
             merges:
                 - oca 8.0
             target: oca aggregated_branch_name
             fetch_all: yes
         """
     config_yaml = dedent(config_yaml)
     repos = config.get_repos(self._parse_config(config_yaml))
     self.assertIs(repos[0]["fetch_all"], True)
示例#9
0
 def test_fetch_all_string(self):
     config_yaml = """
         ./test:
             remotes:
                 oca: https://github.com/test/test.git
             merges:
                 - oca 8.0
             target: oca aggregated_branch_name
             fetch_all: oca
         """
     config_yaml = dedent(config_yaml)
     repos = config.get_repos(self._parse_config(config_yaml))
     self.assertSetEqual(repos[0]["fetch_all"], {"oca"})
示例#10
0
    def test_load(self):
        config_yaml = """
/product_attribute:
    remotes:
        oca: https://github.com/OCA/product-attribute.git
        acsone: git+ssh://[email protected]/acsone/product-attribute.git
    merges:
        - oca 8.0
        - oca refs/pull/105/head
        - oca refs/pull/106/head
    target: acsone aggregated_branch_name
        """
        repos = config.get_repos(self._parse_config(config_yaml))
        self.assertEquals(len(repos), 1)
        # remotes are configured as dict therefore the order is not preserved
        # when parsed
        remotes = repos[0]['remotes']
        repos[0]['remotes'] = []
        self.assertDictEqual(
            repos[0], {
                'cwd':
                '/product_attribute',
                'merges': [{
                    'ref': '8.0',
                    'remote': 'oca'
                }, {
                    'ref': 'refs/pull/105/head',
                    'remote': 'oca'
                }, {
                    'ref': 'refs/pull/106/head',
                    'remote': 'oca'
                }],
                'remotes': [],
                'shell_command_after': [],
                'target': {
                    'branch': 'aggregated_branch_name',
                    'remote': 'acsone'
                }
            })
        assertfn = self.assertItemsEqual if PY2 else self.assertCountEqual
        assertfn(
            remotes,
            [{
                'name': 'oca',
                'url': 'https://github.com/OCA/product-attribute.git'
            }, {
                'name': 'acsone',
                'url': 'git+ssh://[email protected]/acsone/product-attribute.git'
            }])
示例#11
0
    def _bootstrap(self, args):
        """ Bootstrap the git repositories using git aggregator """

        # Mostly adapted from the git aggregator main module with integration
        # into the dob structure
        jobs = max(args.jobs, 1)
        threads = []
        sem = threading.Semaphore(jobs)
        err_queue = Queue()

        default = self.get(base.SECTION, "repo", default={})
        repos = {
            key: utils.merge(default, value, replace=["merges"])
            for key, value in self.get("repos", default={}).items()
        }
        for repo_dict in get_repos(repos, args.force):
            if not err_queue.empty():
                break

            sem.acquire()
            r = Repo(**repo_dict)
            tname = os.path.basename(repo_dict["cwd"])

            if jobs > 1:
                t = threading.Thread(
                    target=aggregate_repo,
                    args=(r, args, sem, err_queue),
                )
                t.daemon = True
                t.name = tname
                threads.append(t)
                t.start()
            else:
                with ThreadNameKeeper():
                    threading.current_thread().name = tname
                    aggregate_repo(r, args, sem, err_queue)

        for t in threads:
            t.join()

        if not err_queue.empty():
            while True:
                try:
                    exc_type, exc_obj, exc_trace = err_queue.get_nowait()
                except Empty:
                    break
                traceback.print_exception(exc_type, exc_obj, exc_trace)
            return 1
示例#12
0
    def test_load(self):
        config_yaml = """
/product_attribute:
    remotes:
        oca: https://github.com/OCA/product-attribute.git
        acsone: git+ssh://[email protected]/acsone/product-attribute.git
    merges:
        - oca 8.0
        - oca refs/pull/105/head
        - oca refs/pull/106/head
    target: acsone aggregated_branch_name
        """
        repos = config.get_repos(self._parse_config(config_yaml))
        self.assertEquals(len(repos), 1)
        # remotes are configured as dict therefore the order is not preserved
        # when parsed
        remotes = repos[0]['remotes']
        repos[0]['remotes'] = []
        self.assertDictEqual(
            repos[0],
            {'cwd': '/product_attribute',
             'merges': [{'ref': '8.0', 'remote': 'oca'},
                        {'ref': 'refs/pull/105/head', 'remote': 'oca'},
                        {'ref': 'refs/pull/106/head', 'remote': 'oca'}],
             'remotes': [],
             'shell_command_after': [],
             'target': {'branch': 'aggregated_branch_name',
                        'remote': 'acsone'}})
        assertfn = self.assertItemsEqual if PY2 else self.assertCountEqual
        assertfn(
            remotes,
            [{'name': 'oca',
              'url': 'https://github.com/OCA/product-attribute.git'},
             {'name': 'acsone',
              'url':
              'git+ssh://[email protected]/acsone/product-attribute.git'}])
示例#13
0
    def test_load_target_exception(self):
        config_yaml = """
/product_attribute:
    remotes:
        oca: https://github.com/OCA/product-attribute.git
    merges:
        - oca 8.0
"""
        with self.assertRaises(ConfigException) as ex:
            config.get_repos(self._parse_config(config_yaml))
        self.assertEquals(ex.exception.args[0],
                          '/product_attribute: No target defined.')

        config_yaml = """
/product_attribute:
    remotes:
        oca: https://github.com/OCA/product-attribute.git
    merges:
        - oca 8.0
    target:
"""
        with self.assertRaises(ConfigException) as ex:
            config.get_repos(self._parse_config(config_yaml))
        self.assertEquals(
            ex.exception.args[0],
            '/product_attribute: Target must be formatted as '
            '"remote_name branch_name"')

        config_yaml = """
/product_attribute:
    remotes:
        oca: https://github.com/OCA/product-attribute.git
    merges:
        - oca 8.0
    target: oba aggregated_branch
"""
        with self.assertRaises(ConfigException) as ex:
            config.get_repos(self._parse_config(config_yaml))
        self.assertEquals(
            ex.exception.args[0],
            '/product_attribute: Target remote oba not defined in remotes.')
示例#14
0
    def test_load_remotes_exception(self):
        config_yaml = """
/product_attribute:
    merges:
        - oca 8.0
    target: oca aggregated_branch
"""
        with self.assertRaises(ConfigException) as ex:
            config.get_repos(self._parse_config(config_yaml))
        self.assertEquals(
            ex.exception.args[0],
            '/product_attribute: remotes is not defined.')

        config_yaml = """
/product_attribute:
    remotes:
    merges:
        - oca 8.0
    target: oca aggregated_branch
"""
        with self.assertRaises(ConfigException) as ex:
            config.get_repos(self._parse_config(config_yaml))
        self.assertEquals(
            ex.exception.args[0],
            '/product_attribute: You should at least define one remote.')

        config_yaml = """
/product_attribute:
    remotes:
        oca:
    merges:
        - oca 8.0
    target: oca aggregated_branch
"""
        with self.assertRaises(ConfigException) as ex:
            config.get_repos(self._parse_config(config_yaml))
        self.assertEquals(
            ex.exception.args[0],
            '/product_attribute: No url defined for remote oca.')
示例#15
0
    def test_load_remotes_exception(self):
        config_yaml = """
/product_attribute:
    merges:
        - oca 8.0
    target: oca aggregated_branch
"""
        with self.assertRaises(ConfigException) as ex:
            config.get_repos(self._parse_config(config_yaml))
        self.assertEquals(ex.exception.args[0],
                          '/product_attribute: remotes is not defined.')

        config_yaml = """
/product_attribute:
    remotes:
    merges:
        - oca 8.0
    target: oca aggregated_branch
"""
        with self.assertRaises(ConfigException) as ex:
            config.get_repos(self._parse_config(config_yaml))
        self.assertEquals(
            ex.exception.args[0],
            '/product_attribute: You should at least define one remote.')

        config_yaml = """
/product_attribute:
    remotes:
        oca:
    merges:
        - oca 8.0
    target: oca aggregated_branch
"""
        with self.assertRaises(ConfigException) as ex:
            config.get_repos(self._parse_config(config_yaml))
        self.assertEquals(
            ex.exception.args[0],
            '/product_attribute: No url defined for remote oca.')