pull-requests: small code cleanup to define other type of merge username...
marcink -
r4191:10d818a8 stable
Not Reviewed
Show More
Add another comment
TODOs: 0 unresolved 0 Resolved
COMMENTS: 0 General 0 Inline
@@ -26,6 +26,8
26
26
27 import json
27 import json
28 import logging
28 import logging
29 import os
30
29 import datetime
31 import datetime
30 import urllib
32 import urllib
31 import collections
33 import collections
@@ -632,6 +634,7
632 repo_id = pull_request.target_repo.repo_id
634 repo_id = pull_request.target_repo.repo_id
633 use_rebase = self._use_rebase_for_merging(pull_request)
635 use_rebase = self._use_rebase_for_merging(pull_request)
634 close_branch = self._close_branch_before_merging(pull_request)
636 close_branch = self._close_branch_before_merging(pull_request)
637 user_name = self._user_name_for_merging(pull_request, user)
635
638
636 target_ref = self._refresh_reference(
639 target_ref = self._refresh_reference(
637 pull_request.target_ref_parts, target_vcs)
640 pull_request.target_ref_parts, target_vcs)
@@ -647,7 +650,6
647 target_vcs.config.set(
650 target_vcs.config.set(
648 'rhodecode', 'RC_SCM_DATA', json.dumps(extras))
651 'rhodecode', 'RC_SCM_DATA', json.dumps(extras))
649
652
650 user_name = user.short_contact
651 merge_state = target_vcs.merge(
653 merge_state = target_vcs.merge(
652 repo_id, workspace_id, target_ref, source_vcs,
654 repo_id, workspace_id, target_ref, source_vcs,
653 pull_request.source_ref_parts,
655 pull_request.source_ref_parts,
@@ -1664,6 +1666,16
1664
1666
1665 return False
1667 return False
1666
1668
1669 def _user_name_for_merging(self, pull_request, user):
1670 env_user_name_attr = os.environ.get('RC_MERGE_USER_NAME_ATTR', '')
1671 if env_user_name_attr and hasattr(user, env_user_name_attr):
1672 user_name_attr = env_user_name_attr
1673 else:
1674 user_name_attr = 'short_contact'
1675
1676 user_name = getattr(user, user_name_attr)
1677 return user_name
1678
1667 def _close_branch_before_merging(self, pull_request):
1679 def _close_branch_before_merging(self, pull_request):
1668 repo_type = pull_request.target_repo.repo_type
1680 repo_type = pull_request.target_repo.repo_type
1669 if repo_type == 'hg':
1681 if repo_type == 'hg':
Comments 0
You need to be logged in to leave comments. Login now