#327 Provide base_module to clone_config templates
Merged 5 years ago by cqi. Opened 5 years ago by tmz.

file modified
+3 -1
@@ -1352,7 +1352,9 @@ 

          conf_git.config('credential.useHttpPath', 'true')

          # Set any other clone_config

          if self.clone_config:

-             clone_config = self.clone_config.strip() % {'module': module}

+             base_module = self.get_base_module(module)

+             clone_config = self.clone_config.strip() % {

+                 'base_module': base_module, 'module': module}

              for confline in clone_config.splitlines():

                  if confline:

                      conf_git.config(*confline.split())

@@ -106,6 +106,26 @@ 

          self.assertTrue(os.path.isdir(clonedir))

          self.assertFalse(os.path.exists(os.path.join(clonedir, 'index')))

  

+     def test_clone_config_template_accepts_base_module(self):

+         self.module = 'rpms/module1'

+         self.base_module = 'module1'

+         self.make_new_git(self.module)

+ 

+         import pyrpkg

why is pyrpkg imported in (almost) every test-case individually? I would prefer one import per file in this case.

cqi commented 5 years ago

Good point. This should be a technical debt in the code. It can be fixed in a separate PR I think.

cqi commented 5 years ago

BTW, I would prefer to rewrite legacy tests based on utils.CommandTestCase that could help to avoid the duplicate and ease the code of self.make_new_git(self.module) and cmd = pyrpkg.Commands(...). This is out of this PR scope. We can fix it later.

+         cmd = pyrpkg.Commands(self.path, self.lookaside, self.lookasidehash,

+                               self.lookaside_cgi, self.gitbaseurl,

+                               self.anongiturl, self.branchre, self.kojiprofile,

+                               self.build_client, self.user, self.dist,

+                               self.target, self.quiet, distgit_namespaced=True)

+         cmd.clone_config = 'bz.default-component %(base_module)s'

+         cmd.clone(self.module, anon=True)

+ 

+         moduledir = os.path.join(self.path, 'module1')

+         self.assertTrue(os.path.isdir(os.path.join(moduledir, '.git')))

+         confgit = git.Git(moduledir)

+         self.assertEqual(confgit.config(

+                          'bz.default-component'), self.base_module)

+ 

      def test_clone_fails_with_both_branch_and_bare_dir(self):

          self.make_new_git(self.module,

                            branches=['rpkg-tests-1', 'rpkg-tests-2'])

When cloning from a namespaced repository, the clone_config template may
wish to use the module with and without the namespace prefix. Use the
get_base_module() function to extract base_module and expand it when
found in a clone_config template.

Resolves: #326
Signed-off-by: Todd Zullinger tmz@pobox.com

This test name confuses me because I can't easily get the point of what it tests. Could you please reconsider and reword it?

Looks good to me except the test name.

Sure. What about test_clone_config_template_uses_base_module or test_clone_config_template_accepts_base_module ? Either could also have _var appended to make it clearer that base_module is a variable.

Thanks.

@tmz test_clone_config_template_accepts_base_module looks good.

rebased onto d2ebfae

5 years ago

Thanks @cqi. I updated my branch with that name.

why is pyrpkg imported in (almost) every test-case individually? I would prefer one import per file in this case.

Good point. This should be a technical debt in the code. It can be fixed in a separate PR I think.

BTW, I would prefer to rewrite legacy tests based on utils.CommandTestCase that could help to avoid the duplicate and ease the code of self.make_new_git(self.module) and cmd = pyrpkg.Commands(...). This is out of this PR scope. We can fix it later.

Going to merge. Thank you all. :tada:

Commit 2aba7d2 fixes this pull-request

Pull-Request has been merged by cqi

5 years ago

Pull-Request has been merged by cqi

5 years ago