def create_codereview_if_neccessary_message(request, issue): """Create a message with a link to create patchset if it's necessary for the issue. If there are pushes after latest patchset, it's necessary to create another patchset to reflect the full set of changes. """ case_id = get_case_id(issue) _, case_title, original_branch, feature_branch, ci_project = get_fogbugz_case_info(case_id) if feature_branch and original_branch: source_vcs, source_url, source_revision, source_branch_is_local, _ = parse_branch_vcs_info( feature_branch, settings.FEATURE_BRANCH_DEFAULT_PREFIX) if os.path.isdir(source_url): source = GuessVCS( attrdict({'revision': source_revision, 'vcs': source_vcs}), source_url) source_revision = source.CheckRevision().strip() if issue.latest_patch_rev != source_revision: messages_api.warning( request, 'There are commits after the latest created patchset. ' 'Please create a <a href="{0}?case={1}">new one</a>'.format( reverse('process_from_fogbugz'), case_id ) ) return ''
def create_codereview_if_neccessary_message(request, issue): """Create a message with a link to create patchset if it's necessary for the issue. If there are pushes after latest patchset, it's necessary to create another patchset to reflect the full set of changes. """ case_id = get_case_id(issue) _, case_title, original_branch, feature_branch, ci_project, target_branch = get_fogbugz_case_info( request, case_id) if feature_branch and original_branch: source_vcs, source_url, source_revision, source_branch_is_local, _ = parse_branch_vcs_info( feature_branch, settings.FEATURE_BRANCH_DEFAULT_PREFIX) if os.path.isdir(source_url): source = GuessVCS( attrdict({ 'revision': source_revision, 'vcs': source_vcs }), source_url) try: source_revision = source.CheckRevision().strip() except RuntimeError: return '' if issue.latest_patch_rev != source_revision: messages_api.warning( request, 'There are commits after the latest created patchset. ' 'Please create a <a href="{0}?case={1}">new one</a>'. format(reverse('process_from_fogbugz'), case_id)) return ''
def test_publish(app, issue2, monkeypatch): """Test publishing comments. Comments are made by user on an issue created by user2. In addition, user will assign the case back to user2. """ def fake_fogbugz_assign_case(request, case_id, target, message, tags): setattr(fake_fogbugz_assign_case, 'case_id', case_id) setattr(fake_fogbugz_assign_case, 'target', target) setattr(fake_fogbugz_assign_case, 'message', message) setattr(fake_fogbugz_assign_case, 'tags', tags) fogbugz_users = ( (5, 'User one'), (10, 'User two'), (15, 'user three'), ) assign_to = fogbugz_users[0] fogbugz_tags = ['tag1', 'tag2'] message = 'test message' monkeypatch.setattr(views, 'get_fogbugz_assignees', lambda case_number: fogbugz_users) monkeypatch.setattr(views, 'fogbugz_assign_case', fake_fogbugz_assign_case) response = app.get('/{0}/publish'.format(issue2.id)) response.forms['publish-form']['assign_to'] = assign_to[0] response.forms['publish-form']['message'] = message response.forms['publish-form']['tags'] = fogbugz_tags submit_response = response.forms['publish-form'].submit() assert submit_response.status_code == 302 assert fake_fogbugz_assign_case.target == unicode(assign_to[0]) assert fake_fogbugz_assign_case.message == unicode(message) assert fake_fogbugz_assign_case.tags == fogbugz_tags assert views.get_case_id(issue2) == fake_fogbugz_assign_case.case_id
def gatekeeper_approve_form(context, request): """Render gatekeeper approval form.""" issue = context['issue'] case_id = get_case_id(issue) form = GatekeeperApprove(case_id) return {'form': form, 'issue': issue}
def fogbugz_case_url(issue): """Get Fogbugz case url out of given issue.""" case_id = get_case_id(issue) return '{settings.FOGBUGZ_URL}default.asp?{case_id}'.format(case_id=case_id, settings=settings)
def fogbugz_case_url(issue): """Get Fogbugz case url out of given issue.""" case_id = get_case_id(issue) return '{settings.FOGBUGZ_URL}default.asp?{case_id}'.format( case_id=case_id, settings=settings)