ome / scc

OME tools for managing the Git(Hub) workflow
https://pypi.org/project/scc/
GNU General Public License v2.0
0 stars 15 forks source link

Fast forward: handle unknown pull requests #250

Closed sbesson closed 4 years ago

sbesson commented 5 years ago

See https://github.com/IDR/deployment/pull/196 for an application. A submodule might point at a fork of a repository meaning it does not contain any of the upstream pull requests parsed during the fast-forward operation.

This is primarily a workaround to fix the merge logic immediately in the case of such repository. More advanced solution could involve disabling the fast-forwarding mechanism or even the processing of some submodules using some configuration/logic TBD.

/cc @manics who encountered this issue recently

sbesson commented 4 years ago

Listing this PR for review as we have been exposed to similar issues recently.

A simple way to test this PR is to use a fork with no existing pull request, set it to a commit behin origin/master and issue a simple merge command. The current release of scc should fail with Failure to get pull request while this branch should only log these failures at the WARN level

$ git clone https://github.com/sbesson/ome-common-java/ && cd ome-common-java && git reset --hard v6.0.2
$ ~/venvs/scc/bin/scc version
0.12.3
$ ~/venvs/scc/bin/scc merge master
2019-10-07 08:47:53,156 [   scc.merge] INFO  Merging Pull Request(s) based on master
2019-10-07 08:47:53,156 [   scc.merge] INFO  Including Pull Request(s) opened by the repository owner
2019-10-07 08:47:53,157 [   scc.merge] INFO  Including Pull Request(s) labelled as include
2019-10-07 08:47:53,157 [   scc.merge] INFO  Excluding Pull Request(s) labelled as exclude or breaking
2019-10-07 08:47:53,593 [    scc.repo] ERROR Failure to get pull request sbesson/ome-common-java#47
Traceback (most recent call last):
  File "/Users/sbesson/venvs/scc/lib/python3.7/site-packages/scc/main.py", line 84, in entry_point
    (UpdateSubmodules.NAME, UpdateSubmodules),
  File "/Users/sbesson/venvs/scc/lib/python3.7/site-packages/yaclifw/framework.py", line 188, in main
    ns.func(ns)
  File "/Users/sbesson/venvs/scc/lib/python3.7/site-packages/scc/git.py", line 3208, in __call__
    self.merge(args, self.main_repo)
  File "/Users/sbesson/venvs/scc/lib/python3.7/site-packages/scc/git.py", line 3238, in merge
    set_commit_status=args.set_commit_status)
  File "/Users/sbesson/venvs/scc/lib/python3.7/site-packages/scc/git.py", line 1799, in rmerge
    pr = self.origin.get_pull(int(s.group(1)))
  File "/Users/sbesson/venvs/scc/lib/python3.7/site-packages/scc/git.py", line 115, in wrapper
    error = check_github_code(e)
  File "/Users/sbesson/venvs/scc/lib/python3.7/site-packages/scc/git.py", line 113, in wrapper
    return func(*args, **kwargs)
  File "/Users/sbesson/venvs/scc/lib/python3.7/site-packages/scc/git.py", line 798, in get_pull
    return self.repo.get_pull(pull_request_number)
  File "/Users/sbesson/venvs/scc/lib/python3.7/site-packages/github/Repository.py", line 2253, in get_pull
    self.url + "/pulls/" + str(number)
  File "/Users/sbesson/venvs/scc/lib/python3.7/site-packages/github/Requester.py", line 276, in requestJsonAndCheck
    return self.__check(*self.requestJson(verb, url, parameters, headers, input, self.__customConnection(url)))
  File "/Users/sbesson/venvs/scc/lib/python3.7/site-packages/github/Requester.py", line 287, in __check
    raise self.__createException(status, responseHeaders, output)
github.GithubException.UnknownObjectException: 404 {'message': 'Not Found', 'documentation_url': 'https://developer.github.com/v3/pulls/#get-a-single-pull-request'}
$ /opt/ome/scc/venv/bin/scc merge master
2019-10-07 08:48:20,759 [   scc.merge] INFO  Merging Pull Request(s) based on master
2019-10-07 08:48:20,759 [   scc.merge] INFO  Including Pull Request(s) opened by the repository owner
2019-10-07 08:48:20,760 [   scc.merge] INFO  Including Pull Request(s) labelled as include
2019-10-07 08:48:20,760 [   scc.merge] INFO  Excluding Pull Request(s) labelled as exclude or breaking
2019-10-07 08:48:23,329 [    scc.repo] ERROR Failure to get pull request sbesson/ome-common-java#47
2019-10-07 08:48:23,329 [     scc.git] WARNI Failed to retrieve 47
Traceback (most recent call last):
  File "build/bdist.macosx-10.13-x86_64/egg/scc/git.py", line 1824, in scan_log
    pr = self.origin.get_pull(int(s.group(1)))
  File "build/bdist.macosx-10.13-x86_64/egg/scc/git.py", line 106, in wrapper
    error = check_github_code(e)
  File "build/bdist.macosx-10.13-x86_64/egg/scc/git.py", line 104, in wrapper
    return func(*args, **kwargs)
  File "build/bdist.macosx-10.13-x86_64/egg/scc/git.py", line 788, in get_pull
    return self.repo.get_pull(pull_request_number)
  File "build/bdist.macosx-10.13-x86_64/egg/github/Repository.py", line 2253, in get_pull
    self.url + "/pulls/" + str(number)
  File "build/bdist.macosx-10.13-x86_64/egg/github/Requester.py", line 276, in requestJsonAndCheck
    return self.__check(*self.requestJson(verb, url, parameters, headers, input, self.__customConnection(url)))
  File "build/bdist.macosx-10.13-x86_64/egg/github/Requester.py", line 287, in __check
    raise self.__createException(status, responseHeaders, output)
UnknownObjectException: 404 {u'documentation_url': u'https://developer.github.com/v3/pulls/#get-a-single-pull-request', u'message': u'Not Found'}
2019-10-07 08:48:23,494 [    scc.repo] ERROR Failure to get pull request sbesson/ome-common-java#45
2019-10-07 08:48:23,494 [     scc.git] WARNI Failed to retrieve 45
Traceback (most recent call last):
  File "build/bdist.macosx-10.13-x86_64/egg/scc/git.py", line 1824, in scan_log
    pr = self.origin.get_pull(int(s.group(1)))
  File "build/bdist.macosx-10.13-x86_64/egg/scc/git.py", line 106, in wrapper
    error = check_github_code(e)
  File "build/bdist.macosx-10.13-x86_64/egg/scc/git.py", line 104, in wrapper
    return func(*args, **kwargs)
  File "build/bdist.macosx-10.13-x86_64/egg/scc/git.py", line 788, in get_pull
    return self.repo.get_pull(pull_request_number)
  File "build/bdist.macosx-10.13-x86_64/egg/github/Repository.py", line 2253, in get_pull
    self.url + "/pulls/" + str(number)
  File "build/bdist.macosx-10.13-x86_64/egg/github/Requester.py", line 276, in requestJsonAndCheck
    return self.__check(*self.requestJson(verb, url, parameters, headers, input, self.__customConnection(url)))
  File "build/bdist.macosx-10.13-x86_64/egg/github/Requester.py", line 287, in __check
    raise self.__createException(status, responseHeaders, output)
UnknownObjectException: 404 {u'documentation_url': u'https://developer.github.com/v3/pulls/#get-a-single-pull-request', u'message': u'Not Found'}
2019-10-07 08:48:23,651 [    scc.repo] ERROR Failure to get pull request sbesson/ome-common-java#44
2019-10-07 08:48:23,651 [     scc.git] WARNI Failed to retrieve 44
Traceback (most recent call last):
  File "build/bdist.macosx-10.13-x86_64/egg/scc/git.py", line 1824, in scan_log
    pr = self.origin.get_pull(int(s.group(1)))
  File "build/bdist.macosx-10.13-x86_64/egg/scc/git.py", line 106, in wrapper
    error = check_github_code(e)
  File "build/bdist.macosx-10.13-x86_64/egg/scc/git.py", line 104, in wrapper
    return func(*args, **kwargs)
  File "build/bdist.macosx-10.13-x86_64/egg/scc/git.py", line 788, in get_pull
    return self.repo.get_pull(pull_request_number)
  File "build/bdist.macosx-10.13-x86_64/egg/github/Repository.py", line 2253, in get_pull
    self.url + "/pulls/" + str(number)
  File "build/bdist.macosx-10.13-x86_64/egg/github/Requester.py", line 276, in requestJsonAndCheck
    return self.__check(*self.requestJson(verb, url, parameters, headers, input, self.__customConnection(url)))
  File "build/bdist.macosx-10.13-x86_64/egg/github/Requester.py", line 287, in __check
    raise self.__createException(status, responseHeaders, output)
UnknownObjectException: 404 {u'documentation_url': u'https://developer.github.com/v3/pulls/#get-a-single-pull-request', u'message': u'Not Found'}
2019-10-07 08:48:23,816 [   scc.merge] INFO  Repository: sbesson/ome-common-java
2019-10-07 08:48:23,817 [   scc.merge] INFO  Updating 726077b..9c239a3
2019-10-07 08:48:23,817 [   scc.merge] INFO  Previously merged:
2019-10-07 08:48:23,817 [   scc.merge] INFO  
2019-10-07 08:48:23,817 [   scc.merge] INFO  
joshmoore commented 4 years ago

Merged v0.12.3 into this branch to make it consumable by devspaces.

joshmoore commented 4 years ago

Releasing as 0.12.4