Show More
@@ -81,6 +81,19 b' class PullrequestsController(BaseRepoCon' | |||||
81 |
|
81 | |||
82 | return hist_l |
|
82 | return hist_l | |
83 |
|
83 | |||
|
84 | def _get_default_rev(self, repo): | |||
|
85 | """ | |||
|
86 | Get's default revision to do compare on pull request | |||
|
87 | ||||
|
88 | :param repo: | |||
|
89 | """ | |||
|
90 | repo = repo.scm_instance | |||
|
91 | if 'default' in repo.branches: | |||
|
92 | return 'default' | |||
|
93 | else: | |||
|
94 | #if repo doesn't have default branch return first found | |||
|
95 | return repo.branches.keys()[0] | |||
|
96 | ||||
84 | def show_all(self, repo_name): |
|
97 | def show_all(self, repo_name): | |
85 | c.pull_requests = PullRequestModel().get_all(repo_name) |
|
98 | c.pull_requests = PullRequestModel().get_all(repo_name) | |
86 | c.repo_name = repo_name |
|
99 | c.repo_name = repo_name | |
@@ -106,7 +119,8 b' class PullrequestsController(BaseRepoCon' | |||||
106 | # add org repo to other so we can open pull request agains itself |
|
119 | # add org repo to other so we can open pull request agains itself | |
107 | c.other_repos.extend(c.org_repos) |
|
120 | c.other_repos.extend(c.org_repos) | |
108 |
|
121 | |||
109 | c.default_pull_request = org_repo.repo_name |
|
122 | c.default_pull_request = org_repo.repo_name # repo name pre-selected | |
|
123 | c.default_pull_request_rev = self._get_default_rev(org_repo) # revision pre-selected | |||
110 | c.default_revs = self._get_repo_refs(org_repo.scm_instance) |
|
124 | c.default_revs = self._get_repo_refs(org_repo.scm_instance) | |
111 | #add orginal repo |
|
125 | #add orginal repo | |
112 | other_repos_info[org_repo.repo_name] = { |
|
126 | other_repos_info[org_repo.repo_name] = { | |
@@ -130,6 +144,8 b' class PullrequestsController(BaseRepoCon' | |||||
130 | #add parents of this fork also |
|
144 | #add parents of this fork also | |
131 | if org_repo.parent: |
|
145 | if org_repo.parent: | |
132 | c.default_pull_request = org_repo.parent.repo_name |
|
146 | c.default_pull_request = org_repo.parent.repo_name | |
|
147 | c.default_pull_request_rev = self._get_default_rev(org_repo.parent) | |||
|
148 | c.default_revs = self._get_repo_refs(org_repo.parent.scm_instance) | |||
133 | c.other_repos.append((org_repo.parent.repo_name, '%s/%s' % ( |
|
149 | c.other_repos.append((org_repo.parent.repo_name, '%s/%s' % ( | |
134 | org_repo.parent.user.username, |
|
150 | org_repo.parent.user.username, | |
135 | org_repo.parent.repo_name)) |
|
151 | org_repo.parent.repo_name)) |
@@ -86,7 +86,18 b' var prevElementSibling = function( el ) ' | |||||
86 | } |
|
86 | } | |
87 | } |
|
87 | } | |
88 |
|
88 | |||
89 |
|
89 | var setSelectValue = function(select, val){ | ||
|
90 | var selection = YUD.get(select); | |||
|
91 | ||||
|
92 | // select element | |||
|
93 | for(var i=0;i<selection.options.length;i++){ | |||
|
94 | console.log(selection.options[i].innerHTML); | |||
|
95 | if (selection.options[i].innerHTML == val) { | |||
|
96 | selection.selectedIndex = i; | |||
|
97 | break; | |||
|
98 | } | |||
|
99 | } | |||
|
100 | } | |||
90 |
|
101 | |||
91 |
|
102 | |||
92 | /** |
|
103 | /** |
@@ -53,7 +53,7 b'' | |||||
53 | <img id="other_repo_gravatar" alt="gravatar" src=""/> |
|
53 | <img id="other_repo_gravatar" alt="gravatar" src=""/> | |
54 | </div> |
|
54 | </div> | |
55 | <span style="font-size: 20px"> |
|
55 | <span style="font-size: 20px"> | |
56 |
${h.select('other_repo',c.default_pull_request ,c.other_repos,class_='refs')}:${h.select('other_ref', |
|
56 | ${h.select('other_repo',c.default_pull_request ,c.other_repos,class_='refs')}:${h.select('other_ref',c.default_pull_request_rev,c.default_revs,class_='refs')} | |
57 | </span> |
|
57 | </span> | |
58 | <div id="other_repo_desc" style="padding:5px 3px 3px 42px;"></div> |
|
58 | <div id="other_repo_desc" style="padding:5px 3px 3px 42px;"></div> | |
59 | </div> |
|
59 | </div> | |
@@ -146,25 +146,29 b'' | |||||
146 | as_form=True)}"; |
|
146 | as_form=True)}"; | |
147 |
|
147 | |||
148 | var select_refs = YUQ('#pull_request_form select.refs') |
|
148 | var select_refs = YUQ('#pull_request_form select.refs') | |
149 |
|
149 | var rev_data = {}; // gather the org/other ref and repo here | ||
150 | for(var i=0;i<select_refs.length;i++){ |
|
150 | for(var i=0;i<select_refs.length;i++){ | |
151 | var select_ref = select_refs[i]; |
|
151 | var select_ref = select_refs[i]; | |
152 | var select_ref_data = select_ref.value.split(':'); |
|
152 | var select_ref_data = select_ref.value.split(':'); | |
153 | var key = null; |
|
153 | var key = null; | |
154 | var val = null; |
|
154 | var val = null; | |
|
155 | ||||
155 | if(select_ref_data.length>1){ |
|
156 | if(select_ref_data.length>1){ | |
156 | key = select_ref.name+"_type"; |
|
157 | key = select_ref.name+"_type"; | |
157 | val = select_ref_data[0]; |
|
158 | val = select_ref_data[0]; | |
158 | url = url.replace(key,val); |
|
159 | url = url.replace(key,val); | |
159 |
|
160 | rev_data[key] = val; | ||
|
161 | ||||
160 | key = select_ref.name; |
|
162 | key = select_ref.name; | |
161 | val = select_ref_data[1]; |
|
163 | val = select_ref_data[1]; | |
162 | url = url.replace(key,val); |
|
164 | url = url.replace(key,val); | |
163 |
|
165 | rev_data[key] = val; | ||
|
166 | ||||
164 | }else{ |
|
167 | }else{ | |
165 | key = select_ref.name; |
|
168 | key = select_ref.name; | |
166 | val = select_ref.value; |
|
169 | val = select_ref.value; | |
167 | url = url.replace(key,val); |
|
170 | url = url.replace(key,val); | |
|
171 | rev_data[key] = val; | |||
168 | } |
|
172 | } | |
169 | } |
|
173 | } | |
170 |
|
174 | |||
@@ -182,6 +186,8 b'' | |||||
182 | YUD.get('other_repo_gravatar').src = other_repos_info[repo_name]['gravatar']; |
|
186 | YUD.get('other_repo_gravatar').src = other_repos_info[repo_name]['gravatar']; | |
183 | YUD.get('other_repo_desc').innerHTML = other_repos_info[repo_name]['description']; |
|
187 | YUD.get('other_repo_desc').innerHTML = other_repos_info[repo_name]['description']; | |
184 | YUD.get('other_ref').innerHTML = other_repos_info[repo_name]['revs']; |
|
188 | YUD.get('other_ref').innerHTML = other_repos_info[repo_name]['revs']; | |
|
189 | // select back the revision that was just compared | |||
|
190 | setSelectValue(YUD.get('other_ref'), rev_data['other_ref']); | |||
185 | }) |
|
191 | }) | |
186 | } |
|
192 | } | |
187 | YUE.on('refresh','click',function(e){ |
|
193 | YUE.on('refresh','click',function(e){ |
General Comments 0
You need to be logged in to leave comments.
Login now