From 922e4f9874cd31bc35e6e9a2282f8e2caf7d97f8 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Mar 03 2017 10:17:23 +0000 Subject: When creating the pull-request, save the commit_start and commit_stop If we were able to compute a list of commits differing between the two repo there is no reason not to save that info in the DB from the start. In addition this will be most useful since it will be announced on the fedmsg message about this new PR and consumer will be able to access and use that info. --- diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py index 7a68975..42d1c19 100644 --- a/pagure/lib/__init__.py +++ b/pagure/lib/__init__.py @@ -1507,7 +1507,8 @@ def new_pull_request(session, branch_from, requestfolder, initial_comment=None, repo_from=None, remote_git=None, requestuid=None, requestid=None, - status='Open', notify=True): + status='Open', notify=True, + commit_start=None, commit_stop=None): ''' Create a new pull request on the specified repo. ''' if not repo_from and not remote_git: raise pagure.exceptions.PagureException( @@ -1528,6 +1529,8 @@ def new_pull_request(session, branch_from, initial_comment=initial_comment or None, user_id=user_obj.id, status=status, + commit_start=commit_start, + commit_stop=commit_stop, ) request.last_updated = datetime.datetime.utcnow() diff --git a/pagure/ui/fork.py b/pagure/ui/fork.py index d8f90e3..c944d03 100644 --- a/pagure/ui/fork.py +++ b/pagure/ui/fork.py @@ -1061,6 +1061,10 @@ def new_request_pull( orig_commit = orig_commit.oid.hex initial_comment = form.initial_comment.data.strip() or None + commit_start = commit_stop = None + if diff_commits: + commit_stop = diff_commits[0].oid.hex + commit_start = diff_commits[-1].oid.hex request = pagure.lib.new_pull_request( SESSION, repo_to=parent, @@ -1071,6 +1075,8 @@ def new_request_pull( initial_comment=initial_comment, user=flask.g.fas_user.username, requestfolder=APP.config['REQUESTS_FOLDER'], + commit_start=commit_start, + commit_stop=commit_stop, ) try: