From 29668f7df713f650f7166ec4557376292f059b14 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Apr 21 2015 14:06:09 +0000 Subject: When viewing a PR against an empty repo, consider all the commits in the fork And adjust the DB to reflect them --- diff --git a/pagure/ui/fork.py b/pagure/ui/fork.py index 901ddb3..e5c7f57 100644 --- a/pagure/ui/fork.py +++ b/pagure/ui/fork.py @@ -284,7 +284,26 @@ def request_pull_patch(repo, requestid, username=None): diff_commits.append(commit) elif orig_repo.is_empty and not repo_obj.is_empty: - diff_commits.append(repo_obj[request.stop_id]) + for commit in repo_obj.walk(commitid, pygit2.GIT_SORT_TIME): + diff_commits.append(commit) + if request.status and diff_commits: + first_commit = repo_obj[diff_commits[-1].oid.hex] + request.commit_start = first_commit.oid.hex + request.commit_stop = diff_commits[0].oid.hex + SESSION.add(request) + try: + SESSION.commit() + pagure.lib.git.update_git( + request, repo=request.project, + repofolder=APP.config['REQUESTS_FOLDER']) + except SQLAlchemyError as err: # pragma: no cover + SESSION.rollback() + APP.logger.exception(err) + flask.flash( + 'Could not update this pull-request in the database', + 'error') + + repo_commit = repo_obj[request.commit_stop] else: flask.flash( 'Fork is empty, there are no commits to request pulling',