Show More
@@ -141,50 +141,42 b' class PullrequestsController(BaseRepoCon' | |||||
141 | # as default for other and thus give a simple compare view |
|
141 | # as default for other and thus give a simple compare view | |
142 | #other_rev = request.POST.get('rev_start') |
|
142 | #other_rev = request.POST.get('rev_start') | |
143 |
|
143 | |||
144 | other_repos_info = {} |
|
|||
145 |
|
||||
146 | c.org_repos = [] |
|
144 | c.org_repos = [] | |
147 | c.org_repos.append((org_repo.repo_name, org_repo.repo_name)) |
|
145 | c.org_repos.append((org_repo.repo_name, org_repo.repo_name)) | |
148 | c.default_org_repo = org_repo.repo_name |
|
146 | c.default_org_repo = org_repo.repo_name | |
149 | c.org_refs, c.default_org_ref = self._get_repo_refs(org_repo.scm_instance, org_rev) |
|
147 | c.org_refs, c.default_org_ref = self._get_repo_refs(org_repo.scm_instance, org_rev) | |
150 |
|
148 | |||
151 | c.other_repos = [] |
|
149 | c.other_repos = [] | |
152 | # add org repo to other so we can open pull request against itself |
|
150 | other_repos_info = {} | |
153 | c.other_repos.extend(c.org_repos) |
|
151 | ||
|
152 | def add_other_repo(repo, branch_rev=None): | |||
|
153 | if repo.repo_name in other_repos_info: # shouldn't happen | |||
|
154 | return | |||
|
155 | c.other_repos.append((repo.repo_name, repo.repo_name)) | |||
|
156 | other_refs, selected_other_ref = self._get_repo_refs(repo.scm_instance, branch_rev=branch_rev) | |||
|
157 | other_repos_info[repo.repo_name] = { | |||
|
158 | 'user': dict(user_id=repo.user.user_id, | |||
|
159 | username=repo.user.username, | |||
|
160 | firstname=repo.user.firstname, | |||
|
161 | lastname=repo.user.lastname, | |||
|
162 | gravatar_link=h.gravatar_url(repo.user.email, 14)), | |||
|
163 | 'description': repo.description, | |||
|
164 | 'revs': h.select('other_ref', selected_other_ref, other_refs, class_='refs') | |||
|
165 | } | |||
|
166 | ||||
|
167 | # add org repo to other so we can open pull request against peer branches on itself | |||
|
168 | add_other_repo(org_repo, branch_rev=org_rev) | |||
154 | c.default_other_repo = org_repo.repo_name |
|
169 | c.default_other_repo = org_repo.repo_name | |
155 | other_refs, other_ref = self._get_repo_refs(org_repo.scm_instance, branch_rev=org_rev) |
|
|||
156 | usr_data = lambda usr: dict(user_id=usr.user_id, |
|
|||
157 | username=usr.username, |
|
|||
158 | firstname=usr.firstname, |
|
|||
159 | lastname=usr.lastname, |
|
|||
160 | gravatar_link=h.gravatar_url(usr.email, 14)) |
|
|||
161 | other_repos_info[org_repo.repo_name] = { |
|
|||
162 | 'user': usr_data(org_repo.user), |
|
|||
163 | 'description': org_repo.description, |
|
|||
164 | 'revs': h.select('other_ref', other_ref, other_refs, class_='refs') |
|
|||
165 | } |
|
|||
166 |
|
170 | |||
167 | # gather forks and add to this list ... even though it is rare to |
|
171 | # gather forks and add to this list ... even though it is rare to | |
168 | # request forks to pull from their parent |
|
172 | # request forks to pull from their parent | |
169 | for fork in org_repo.forks: |
|
173 | for fork in org_repo.forks: | |
170 | c.other_repos.append((fork.repo_name, fork.repo_name)) |
|
174 | add_other_repo(fork) | |
171 | refs, default_ref = self._get_repo_refs(fork.scm_instance) |
|
|||
172 | other_repos_info[fork.repo_name] = { |
|
|||
173 | 'user': usr_data(fork.user), |
|
|||
174 | 'description': fork.description, |
|
|||
175 | 'revs': h.select('other_ref', default_ref, refs, class_='refs') |
|
|||
176 | } |
|
|||
177 |
|
175 | |||
178 | # add parents of this fork also, but only if it's not empty |
|
176 | # add parents of this fork also, but only if it's not empty | |
179 | if org_repo.parent and org_repo.parent.scm_instance.revisions: |
|
177 | if org_repo.parent and org_repo.parent.scm_instance.revisions: | |
|
178 | add_other_repo(org_repo.parent) | |||
180 | c.default_other_repo = org_repo.parent.repo_name |
|
179 | c.default_other_repo = org_repo.parent.repo_name | |
181 | other_refs, other_ref = self._get_repo_refs(org_repo.parent.scm_instance) |
|
|||
182 | c.other_repos.append((org_repo.parent.repo_name, org_repo.parent.repo_name)) |
|
|||
183 | other_repos_info[org_repo.parent.repo_name] = { |
|
|||
184 | 'user': usr_data(org_repo.parent.user), |
|
|||
185 | 'description': org_repo.parent.description, |
|
|||
186 | 'revs': h.select('other_ref', other_ref, other_refs, class_='refs') |
|
|||
187 | } |
|
|||
188 |
|
180 | |||
189 | c.default_other_repo_info = other_repos_info[c.default_other_repo] |
|
181 | c.default_other_repo_info = other_repos_info[c.default_other_repo] | |
190 | c.other_repos_info = json.dumps(other_repos_info) |
|
182 | c.other_repos_info = json.dumps(other_repos_info) |
General Comments 0
You need to be logged in to leave comments.
Login now