#475 Add check for wrong repo name format during clone
Merged 4 years ago by onosek. Opened 4 years ago by onosek.
onosek/rpkg clone_repo_name  into  master

file modified
+18 -47
@@ -1377,32 +1377,16 @@ 

              namespace rpms will set.

          :rtype: str

          """

- 

-         if self.distgit_namespaced:

-             if '/' in repo_name:

-                 giturl = self.gitbaseurl % {

-                     'user': self.user,

-                     'repo': repo_name,

-                     # This is for the compatible with old format

-                     'module': repo_name,

-                 }

-             else:

-                 # Default to rpms namespace for backwards compat

-                 rpms_repo_name = 'rpms/%s' % repo_name

-                 giturl = self.gitbaseurl % {

-                     'user': self.user,

-                     'repo': rpms_repo_name,

-                     # This is for the compatible with old format

-                     'module': rpms_repo_name,

-                 }

-         else:

-             giturl = self.gitbaseurl % {

-                 'user': self.user,

-                 'repo': repo_name,

-                 # This is for the compatible with old format

-                 'module': repo_name

-             }

- 

+         if self.distgit_namespaced and '/' not in repo_name:

+             # Default to rpms namespace for backwards compat

+             repo_name = 'rpms/%s' % repo_name

+ 

+         giturl = self.gitbaseurl % {

+             'user': self.user,

+             'repo': repo_name,

+             # This is for the compatible with old format

+             'module': repo_name

+         }

          return giturl

  

      def _get_namespace_anongiturl(self, repo_name):
@@ -1414,28 +1398,15 @@ 

              namespace rpms will be set.

          :rtype: str

          """

+         if self.distgit_namespaced and '/' not in repo_name:

+             # Default to rpms namespace for backwards compat

+             repo_name = 'rpms/%s' % repo_name

  

-         if self.distgit_namespaced:

-             if '/' in repo_name:

-                 giturl = self.anongiturl % {

-                     'repo': repo_name,

-                     # This is for the compatible with old format

-                     'module': repo_name,

-                 }

-             else:

-                 rpms_repo_name = 'rpms/%s' % repo_name

-                 # Default to rpms namespace for backwards compat

-                 giturl = self.anongiturl % {

-                     'repo': rpms_repo_name,

-                     # This is for the compatible with old format

-                     'module': rpms_repo_name,

-                 }

-         else:

-             giturl = self.anongiturl % {

-                 'repo': repo_name,

-                 'module': repo_name,

-             }

- 

+         giturl = self.anongiturl % {

+             'repo': repo_name,

+             # This is for the compatible with old format

+             'module': repo_name,

+         }

          return giturl

  

      def add_tag(self, tagname, force=False, message=None, file=None):

file modified
+6
@@ -1906,6 +1906,12 @@ 

          self.cmd.clog(raw=self.args.raw)

  

      def clone(self):

+         # corrects user-given wrong format of a repo name

+         if self.args.repo[0].endswith('.git'):

+             repo = self.args.repo[0][:-4]

+             self.log.warn("Repo name should't contain '.git' suffix. "

+                           "Correcting the repo name: '%s'" % repo)

+ 

          if self.args.branches:

              self.cmd.clone_with_dirs(self.args.repo[0],

                                       anon=self.args.anonymous,

"clone" method in fedpkg accepted repo name with .git extension. It cloned repo successfully, but during configuration of the repo it failed, because of wrong directory name derived from the repo name. Now rpkg checks (and modifies) the correct format at the beginning of the process.

Another commit in PR simplifies methods for getting namespace giturl. There were some unnecessary duplications.

Why not double quotes and dropping the backslashes?

Why not double quotes and dropping the backslashes?

No clever reason. I will change it to double-quotes. Quotes in the file are already mixed.

2 new commits added

  • Add check for wrong repo name format during clone
  • Simplify methods for getting namespace giturl
4 years ago

Pull-Request has been merged by onosek

4 years ago