#905 frontend: fix pagure-events service for forked projects
Closed 4 years ago by frostyx. Opened 4 years ago by frostyx.
copr/ frostyx/copr fix-pagure-events-for-forks  into  master

@@ -273,7 +273,8 @@ 

              log.info('Received event was discarded. Continuing.')

              continue

  

-         candidates = ScmPackage.get_candidates_for_rebuild(event_info.base_clone_url)

+         base_clone_url = os.path.join(base_url, event_info.base_project_url_path)

+         candidates = ScmPackage.get_candidates_for_rebuild(base_clone_url)

If you look at how base_clone_url is defined:
'base_clone_url': base_url + data['msg']['pullrequest']['project']['fullname']

It seems to be pagure's fault (why would they put forks into fullname, and not fork). Could you please create the issue, and link it from commit message?

Also, shouldn't we rather correctly define the event.base_clone_url in event_info_from* methods?

          changed_files = set()

  

          if candidates:
@@ -304,7 +305,7 @@ 

              log.info('Considering pkg package: {}, source_json: {}'

                          .format(package, pkg.source_json_dict))

  

-             if (git_compare_urls(pkg.clone_url, event_info.base_clone_url)

+             if (git_compare_urls(pkg.clone_url, base_clone_url)

                      and (not pkg.committish or event_info.branch_to.endswith(pkg.committish))

                      and pkg.is_dir_in_commit(changed_files)):

  
@@ -322,7 +323,7 @@ 

                      scm_object_url = os.path.join(base_url, event_info.base_project_url_path,

                                                    'c', str(event_info.object_id))

  

-                 if not git_compare_urls(pkg.copr.scm_repo_url, event_info.base_clone_url):

+                 if not git_compare_urls(pkg.copr.scm_repo_url, base_clone_url):

                      update_callback = ''

  

                  source_dict_update = {

When creating a PR for pagure project that is a fork of some other
project, our pagure-events service is not able to trigger package
rebuilds in Copr. It doesn't find any candidates with

ScmPackage.get_candidates_for_rebuid(event_info.base_clone_url)

That is because event_info.base_clone_url looks like this

https://pagure.io/forks/frostyx/copr/copr

but really, the URL is supposed to be

https://pagure.io/fork/frostyx/copr/copr

The first url returns 404. I don't know whether this is a pagure
or our issue, but I am fixing/workaround it here, so we don't
eventually need to wait for pagure release to get this fixed.

If you look at how base_clone_url is defined:
'base_clone_url': base_url + data['msg']['pullrequest']['project']['fullname']

It seems to be pagure's fault (why would they put forks into fullname, and not fork). Could you please create the issue, and link it from commit message?

Also, shouldn't we rather correctly define the event.base_clone_url in event_info_from* methods?

This PR seems to not be required anymore. Now when I open my fork and hit clone, I get this URL

https://pagure.io/forks/frostyx/copr/copr.git

which returns 404, but is indeed clonable with git. If I set it as my package SCM URL, then I have automatic rebuilds from PRs working without requiring this PR, so I propose to just close it.

Pull-Request has been closed by frostyx

4 years ago