#596 Fork a package using anonymous auth
Merged 2 months ago by onosek. Opened 2 months ago by onosek.
onosek/fedpkg anonymous_fork  into  master

file modified
+11 -1
@@ -531,6 +531,11 @@ 

              formatter_class=argparse.RawDescriptionHelpFormatter,

              help=help_msg,

              description=description)

+         fork_parser.add_argument(

+             '--anonymous', '-a', action='store_true',

+             help='In this mode, it is possible to fork the repository which was cloned '

+                  '"anonymously" (fedpkg clone -a). The forked repository uses https '

+                  'protocol instead ssh.')

          fork_parser.set_defaults(command=self.do_distgit_fork)

  

      def register_releases_info(self):
@@ -1300,11 +1305,16 @@ 

          That includes creating fork itself using API call and then adding

          remote tracked repository

          """

+         anon = self.args.anonymous

+         if self.cmd.push_url.startswith('https://'):

+             anon = True

+             self.log.info('Detected anonymously cloned repo (`fedpkg clone -a`) '

+                           '- forking in the anonymous mode.')

          distgit_section = '{0}.distgit'.format(self.name)

          distgit_api_base_url = config_get_safely(self.config, distgit_section, "apibaseurl")

          distgit_remote_base_url = self.config.get(

              '{0}'.format(self.name),

-             "gitbaseurl",

+             'anongiturl' if anon else 'gitbaseurl',

              vars={'user': self.cmd.user, 'repo': self.cmd.repo_name},

          )

          distgit_token = config_get_safely(self.config, distgit_section, 'token')

When the repo is cloned anonymously (fedpkg clone -a), fork should work in the 'anonymous' mode as well. Fork API call is the same, but the added remote has a different address = https protocol instead of ssh.
Fedpkg detects whether fork is executed upon an anonymous repo. The User can force anonymous mode using (fedpkg fork -a) parameter.

Fixes: #574
JIRA: RHELCMP-14205

Signed-off-by: Ondřej Nosek onosek@redhat.com

rebased onto 6b7a842

2 months ago

Pull-Request has been merged by onosek

2 months ago
Metadata