commit.html 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  1. {% extends "repo_master.html" %}
  2. {% block title %}Commit - {{
  3. repo.namespace + '/' if repo.namespace }}{{ repo.name }} - {{ commitid }}{% endblock %}
  4. {% set tag = "commit"%}
  5. {% block header %}
  6. <link rel="stylesheet" nonce="{{ g.nonce }}" href="{{
  7. url_for('static', filename='vendor/highlight.js/styles/github.css') }}?version={{ g.version}}"/>
  8. <link rel="stylesheet" nonce="{{ g.nonce }}" href="{{
  9. url_for('static', filename='vendor/diff2html/diff2html.css') }}?version={{ g.version}}"/>
  10. {% if splitview %}
  11. <style nonce="{{ g.nonce }}">
  12. .repo-body-container{max-width:100%!important}
  13. </style>
  14. {% endif %}
  15. {% endblock %}
  16. {% block repo %}
  17. {% set splitted_message = commit.message.split('\n') %}
  18. {# we recognize non-executable file, executable file and symlink #}
  19. {% set expected_modes = [33188, 33261, 40960] %}
  20. <div class="row">
  21. <div class="col-2">
  22. {% block overviewtabs %}{{ super() }}{% endblock %}
  23. </div>
  24. <div class="col-10">
  25. <div class="d-flex">
  26. <div>
  27. <h4 class="font-weight-bold">
  28. <span title="{{ commitid }}"><code class="text-white bg-primary">{{ commitid|short }}</code></span>
  29. <span>{{ splitted_message[0] }}</span>
  30. </h4>
  31. <h5 class="text-muted pt-1 mb-0">
  32. {% if commit.author| author2user == commit.committer| author2user %}
  33. {% if commit.parents | length == 1 %}
  34. Authored and Committed by {{ commit.author | author2user |safe }}
  35. {% else %}
  36. Merged and Committed by {{ commit.author | author2user |safe }}
  37. {% endif %}
  38. {{ commit.commit_time | humanize_tooltip | safe }}
  39. {% else %}
  40. <a href="#" id="diff_list_link">{{ diff|count}} file{{'s' if diff|count > 1 }}</a>
  41. {% if commit.parents | length == 1 %}
  42. Authored by {{ commit.author | author2user |safe }}
  43. {% else %}
  44. Merged by {{ commit.author | author2user |safe }}
  45. {% endif %}
  46. {{ commit.commit_time | humanize_tooltip | safe }},
  47. Committed by {{ commit.committer | author2user |safe }}
  48. {{ commit.commit_time | humanize_tooltip | safe }},
  49. {% endif%}
  50. </h5>
  51. </div>
  52. <div class="ml-auto">
  53. <div class="btn-group">
  54. <a class="btn btn-outline-primary btn-sm" href="{{ url_for(
  55. 'ui_ns.view_raw_file',
  56. repo=repo.name,
  57. username=username,
  58. namespace=repo.namespace,
  59. identifier=commitid) }}" title="View as raw">raw</a>
  60. <a class="btn btn-outline-primary btn-sm" href="{{ url_for(
  61. 'ui_ns.view_commit_patch',
  62. repo=repo.name,
  63. username=username,
  64. namespace=repo.namespace,
  65. commitid=commitid) }}">patch</a>
  66. <a class="btn btn-outline-primary btn-sm" href="{{ url_for(
  67. 'ui_ns.view_tree', username=username, namespace=repo.namespace,
  68. repo=repo.name, identifier=commitid) }}">tree</a>
  69. {% if commit.parents|length == 1 %}
  70. <a class="btn btn-outline-primary btn-sm" title={{commit.parents[0].oid.hex}} href="{{ url_for(
  71. 'ui_ns.view_commit',
  72. repo=repo.name,
  73. username=username,
  74. namespace=repo.namespace,
  75. commitid=commit.parents[0].oid.hex) }}">parent</a>
  76. {% elif commit.parents|length > 1 %}
  77. <div class="btn-group" role="group">
  78. <button id="parentsDrop" type="button" class="btn btn-secondary btn-sm dropdown-toggle"
  79. data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  80. parents
  81. </button>
  82. <div class="dropdown-menu dropdown-menu-right" aria-labelledby="parentsDrop">
  83. {% for parent in commit.parents %}
  84. <a class="dropdown-item" href="{{ url_for(
  85. 'ui_ns.view_commit',
  86. repo=repo.name,
  87. username=username,
  88. namespace=repo.namespace,
  89. commitid=parent.oid.hex)
  90. }}" class="commitid">{{parent.oid.hex}}</a>
  91. {% endfor %}
  92. </div>
  93. </div>
  94. {% endif%}
  95. </div>
  96. </div>
  97. </div>
  98. {% macro changeschangedfile(filepath, added, removed, diffanchor) -%}
  99. <a href="#_{{diffanchor}}" class="list-group-item list-group-item-action">
  100. <div class="d-flex">
  101. <div class="font-weight-bold">
  102. {{ filepath | unicode }}
  103. </div>
  104. <div class="ml-auto font-weight-bold">
  105. <span class="font-weight-bold btn btn-sm btn-outline-secondary border-0 disabled opacity-100">file modified</span>
  106. <div class="btn-group">
  107. <span class="font-weight-bold btn btn-sm btn-success disabled opacity-100">+{{added}}</span>
  108. <span class="font-weight-bold btn btn-sm btn-danger disabled opacity-100">-{{removed}}</span>
  109. </div>
  110. </div>
  111. </div>
  112. </a>
  113. {%- endmacro %}
  114. {% macro changesrenamedfile(oldfilepath, newfilepath, added, removed, diffanchor) -%}
  115. <a href="#_{{diffanchor}}" class="list-group-item list-group-item-action">
  116. <div class="d-flex">
  117. <div class="font-weight-bold">
  118. {{ newfilepath | unicode }}<strike>{{ oldfilepath | unicode }}</strike>
  119. </div>
  120. <div class="ml-auto font-weight-bold">
  121. <span class="font-weight-bold btn btn-sm btn-outline-info border-0 disabled opacity-100">file renamed</span>
  122. <div class="btn-group">
  123. <span class="font-weight-bold btn btn-sm btn-success disabled opacity-100">+{{added}}</span>
  124. <span class="font-weight-bold btn btn-sm btn-danger disabled opacity-100">-{{removed}}</span>
  125. </div>
  126. </div>
  127. </div>
  128. </a>
  129. {%- endmacro %}
  130. {% macro changesdeletedfile(filepath, added, removed, diffanchor) -%}
  131. <a href="#_{{diffanchor}}" class="list-group-item list-group-item-action">
  132. <div class="d-flex">
  133. <div class="font-weight-bold">
  134. {{filepath | unicode }}
  135. </div>
  136. <div class="ml-auto font-weight-bold">
  137. <span class="font-weight-bold btn btn-sm btn-outline-danger border-0 disabled opacity-100">file removed</span>
  138. <div class="btn-group">
  139. <span class="font-weight-bold btn btn-sm btn-danger disabled opacity-100">-{{removed}}</span>
  140. </div>
  141. </div>
  142. </div>
  143. </a>
  144. {%- endmacro %}
  145. {% macro changesaddedfile(filepath, added, removed, diffanchor) -%}
  146. <a href="#_{{diffanchor}}" class="list-group-item list-group-item-action">
  147. <div class="d-flex">
  148. <div class="font-weight-bold">
  149. {{filepath | unicode }}
  150. </div>
  151. <div class="ml-auto font-weight-bold">
  152. <span class="font-weight-bold btn btn-sm btn-outline-success border-0 disabled opacity-100">file added</span>
  153. <div class="btn-group">
  154. <span class="font-weight-bold btn btn-sm btn-success disabled opacity-100">+{{added}}</span>
  155. </div>
  156. </div>
  157. </div>
  158. </a>
  159. {%- endmacro %}
  160. <div class="card border-0 mb-3">
  161. <div class="card-header border-0 bg-white font-weight-bold p-0">
  162. <a href="#commit-overview-collapse" data-toggle="collapse" data-target="#commit-overview-collapse">{{diff.stats.files_changed}} file{{'s' if diff.stats.files_changed > 1 }} changed.</a>
  163. <span class="text-success">{{diff.stats.insertions}} lines added</span>.
  164. <span class="text-danger">{{diff.stats.deletions}} lines removed</span>.
  165. </div>
  166. <div class="card-body p-0 collapse" id="commit-overview-collapse">
  167. <div class="list-group ">
  168. {% for patch in diff %}
  169. {% set linesadded = patch.line_stats[1] %}
  170. {% set linesremoved = patch.line_stats[2] %}
  171. {% if patch | hasattr('new_file_path') %}
  172. {%- if patch.new_file_path == patch.old_file_path -%}
  173. {%- if patch.status == 'D' -%}
  174. {{ changesdeletedfile(patch.new_file_path, linesadded, linesremoved, loop.index) }}
  175. {%- elif patch.status == 'A' -%}
  176. {{ changesaddedfile(patch.new_file_path | string, linesadded, linesremoved, loop.index) }}
  177. {%- elif patch.status == 'M' -%}
  178. {{ changeschangedfile(patch.new_file_path, linesadded, linesremoved, loop.index) }}
  179. {%-endif-%}
  180. {%- else -%}
  181. {{changesrenamedfile(patch.old_file_path, patch.new_file_path, linesadded, linesremoved, loop.index)}}
  182. {%- endif -%}
  183. {%- elif patch | hasattr('delta') -%}
  184. {%- if patch.delta.new_file.path == patch.delta.old_file.path -%}
  185. {%- if patch.delta.new_file.mode == 0
  186. and patch.delta.old_file.mode in expected_modes -%}
  187. {{ changesdeletedfile(patch.delta.new_file.path, linesadded, linesremoved, loop.index) }}
  188. {%- elif patch.delta.new_file.mode in expected_modes
  189. and patch.delta.old_file.mode == 0 -%}
  190. {{ changesaddedfile( patch.delta.new_file.path, linesadded, linesremoved, loop.index) }}
  191. {%- elif patch.delta.new_file.mode in expected_modes
  192. and patch.delta.old_file.mode in expected_modes -%}
  193. {{ changeschangedfile(patch.delta.new_file.path, linesadded, linesremoved, loop.index) }}
  194. {%-endif-%}
  195. {%- else -%}
  196. {{changesrenamedfile(patch.delta.old_file.path, patch.delta.new_file.path, linesadded, linesremoved, loop.index)}}
  197. {%- endif -%}
  198. {%- endif -%}
  199. {% endfor %}
  200. </div>
  201. </div>
  202. </div>
  203. <div class="m-y-1">
  204. {% if splitted_message|length > 1 %}
  205. <pre class="commit_message_body">
  206. {% for message in splitted_message %}
  207. {{ message | linkify | safe}}
  208. {% endfor %}
  209. </pre>
  210. {% endif %}
  211. </div>
  212. {% if flags %}
  213. <section class="list-group" id="flag_list">
  214. <div class="card" id="pr_flags">
  215. <ul class="list-group list-group-flush">
  216. {% for flag in flags %}
  217. <li class="list-group-item">
  218. <div>
  219. <span>
  220. <a href="{{ flag.url }}">{{ flag.username }}</a>
  221. </span>
  222. <div class="pull-xs-right">
  223. <span class="badge {{ flag | flag2label }}">
  224. {{- flag.status -}}
  225. {%- if flag.percent %} ({{ flag.percent }}%) {%- endif -%}
  226. </span>
  227. </div>
  228. </div>
  229. <small><div class="clearfix">
  230. <span>{{ flag.comment }}</span>
  231. <div title="{% if
  232. flag.date_created == flag.date_updated -%}
  233. Created at {% else -%} Updated at {% endif -%}
  234. {{ flag.date_updated }}" class="pull-xs-right">
  235. {{ flag.date_updated | humanize_tooltip | safe }}</div>
  236. </div>
  237. </small>
  238. </li>
  239. {% endfor %}
  240. </ul>
  241. </div>
  242. </section>
  243. {% endif %}
  244. {% if diff %}
  245. {% for patch in diff %}
  246. {% if patch |hasattr('new_id') %}
  247. {% set patch_new_id = patch.new_id %}
  248. {% elif patch |hasattr('delta') %}
  249. {% set patch_new_id = patch.delta.new_file.id %}
  250. {% else %}
  251. {% set patch_new_id = patch.new_oid %}
  252. {% endif %}
  253. {% if patch |hasattr('old_id') %}
  254. {% set patch_old_id = patch.old_id %}
  255. {% elif patch |hasattr('delta') %}
  256. {% set patch_old_id = patch.delta.old_file.id %}
  257. {% else %}
  258. {% set patch_old_id = patch.old_oid %}
  259. {% endif %}
  260. {% if patch | hasattr('new_file_path') %}
  261. {% set patch_new_file_path = patch.new_file_path -%}
  262. {% if patch.new_file_path != patch.old_file_path %}
  263. {% set patch_old_file_path = patch.old_file_path %}
  264. {%- endif -%}
  265. {%- elif patch | hasattr('delta') -%}
  266. {% set patch_new_file_path = patch.delta.new_file.path -%}
  267. {%- if patch.delta.new_file.path != patch.delta.old_file.path -%}
  268. {% set patch_old_file_path = patch.delta.old_file.path %}
  269. {%- endif -%}
  270. {%- endif -%}
  271. <section class="commit_diff">
  272. <div class="card mt-3" id="_{{loop.index}}">
  273. <div class="card-header">
  274. <div class="d-flex align-items-center">
  275. {% set linesadded = patch.line_stats[1] %}
  276. {% set linesremoved = patch.line_stats[2] %}
  277. {% macro lineschanged(added, removed) -%}
  278. <div class="btn-group">
  279. {%if added%}
  280. <span class="btn btn-success btn-sm font-weight-bold disabled opacity-100">+{{linesadded}}</span>
  281. {%endif%}
  282. {%if removed%}
  283. <span class="btn btn-danger btn-sm font-weight-bold disabled opacity-100">-{{linesremoved}}</span>
  284. {%endif%}
  285. </div>
  286. {%endmacro%}
  287. {% macro viewfilelink(filepath)%}
  288. <a class="font-weight-bold ml-2" href="{{
  289. url_for(
  290. 'ui_ns.view_file',
  291. repo=repo.name,
  292. username=username,
  293. namespace=repo.namespace,
  294. identifier=commitid,
  295. filename=filepath) }}"
  296. title="View file as of {{ commitid|short }}">{{
  297. filepath | unicode }}</a>
  298. {% endmacro %}
  299. {% macro viewfilelinkbutton(filepath, disabled=False)%}
  300. <a class="btn btn-outline-primary {{'disabled' if disabled}} btn-sm ml-2" href="{{
  301. url_for(
  302. 'ui_ns.view_file',
  303. repo=repo.name,
  304. username=username,
  305. namespace=repo.namespace,
  306. identifier=commitid,
  307. filename=filepath) }}"
  308. title="View file as of {{ commitid|short }}">
  309. <i class="fa fa-file-code-o fa-fw"></i>
  310. </a>
  311. {% endmacro %}
  312. {% macro changedlabel(thelabel, thecolor)%}
  313. <div class="btn btn-outline-{{thecolor}} disabled opacity-100 border-0 font-weight-bold">
  314. {{- thelabel -}}
  315. </div>
  316. {% endmacro %}
  317. {% macro diffcollapsebtn()%}
  318. <a href="diff2html_{{loop.index}}" class="btn btn-sm btn-outline-primary diffcollapse ml-2" data-toggle="collapse" data-target="#diff2html_{{loop.index}}">
  319. <i class="fa fa-fw fa-caret-up"></i>
  320. </a>
  321. {% endmacro %}
  322. {% if patch | hasattr('new_file_path') %}
  323. {%- if patch.new_file_path == patch.old_file_path -%}
  324. {%- if patch.status == 'D' -%}
  325. {% set patchtype = "removed"%}
  326. <div>
  327. {{ viewfilelink(patch.new_file.path) }}
  328. </div>
  329. <div class="d-flex align-items-center ml-auto">
  330. {{ changedlabel("file removed", "danger")}}
  331. {{ lineschanged(False, True) }}
  332. {{ viewfilelinkbutton(patch.new_file.path, disabled=True) }}
  333. {{ diffcollapsebtn() }}
  334. </div>
  335. {%-elif patch.status == 'A' -%}
  336. {% set patchtype = "added"%}
  337. <div>
  338. {{ viewfilelink(patch.new_file.path) }}
  339. </div>
  340. <div class="d-flex align-items-center ml-auto">
  341. {{ changedlabel("file added", "success")}}
  342. {{ lineschanged(True, False) }}
  343. {{ viewfilelinkbutton(patch.new_file.path) }}
  344. {% if linesadded != 0%}
  345. {{ diffcollapsebtn() }}
  346. {% endif %}
  347. </div>
  348. {%-elif patch.status == 'M' -%}
  349. {% set patchtype = "changed"%}
  350. <div>
  351. {{ viewfilelink(patch.new_file.path) }}
  352. </div>
  353. <div class="d-flex align-items-center ml-auto">
  354. {{ changedlabel("file modified", "secondary")}}
  355. {{ lineschanged(True, True) }}
  356. {{ viewfilelinkbutton(patch.new_file.path) }}
  357. {{ diffcollapsebtn() }}
  358. </div>
  359. {%-endif-%}
  360. {%- else -%}
  361. {% set patchtype = "moved"%}
  362. <div>
  363. {{ viewfilelink(patch.new_file.path) }}<strike>{{patch.old_file.path}}</strike>
  364. </div>
  365. <div class="d-flex align-items-center ml-auto">
  366. {{ changedlabel("file renamed", "info")}}
  367. {% if linesadded != 0 and linesremoved != 0%}
  368. {{ lineschanged(True, True) }}
  369. {% endif %}
  370. {{ viewfilelinkbutton(patch.new_file.path) }}
  371. {% if linesadded != 0 and linesremoved != 0%}
  372. {{ diffcollapsebtn() }}
  373. {% endif %}
  374. </div>
  375. {%- endif -%}
  376. {%- elif patch | hasattr('delta') -%}
  377. {%- if patch.delta.new_file.path == patch.delta.old_file.path -%}
  378. {%- if patch.delta.new_file.mode == 0
  379. and patch.delta.old_file.mode in expected_modes -%}
  380. {% set patchtype = "removed"%}
  381. <div>
  382. {{ viewfilelink(patch.delta.new_file.path) }}
  383. </div>
  384. <div class="d-flex align-items-center ml-auto">
  385. {{ changedlabel("file removed", "danger")}}
  386. {{ lineschanged(False, True) }}
  387. {{ viewfilelinkbutton(patch.delta.new_file.path, disabled=True) }}
  388. {{ diffcollapsebtn() }}
  389. </div>
  390. {%-elif patch.delta.new_file.mode in expected_modes
  391. and patch.delta.old_file.mode == 0 -%}
  392. {% set patchtype = "added"%}
  393. <div>
  394. {{ viewfilelink(patch.delta.new_file.path) }}
  395. </div>
  396. <div class="d-flex align-items-center ml-auto">
  397. {{ changedlabel("file added", "success")}}
  398. {{ lineschanged(True, False) }}
  399. {{ viewfilelinkbutton(patch.delta.new_file.path) }}
  400. {% if linesadded != 0%}
  401. {{ diffcollapsebtn() }}
  402. {% endif %}
  403. </div>
  404. {%-elif patch.delta.new_file.mode in expected_modes
  405. and patch.delta.old_file.mode in expected_modes -%}
  406. {% set patchtype = "changed"%}
  407. <div>
  408. {{ viewfilelink(patch.delta.new_file.path) }}
  409. </div>
  410. <div class="d-flex align-items-center ml-auto">
  411. {{ changedlabel("file modified", "secondary")}}
  412. {{ lineschanged(True, True) }}
  413. {{ viewfilelinkbutton(patch.delta.new_file.path) }}
  414. {{ diffcollapsebtn() }}
  415. </div>
  416. {%-endif-%}
  417. {%- else -%}
  418. {% set patchtype = "moved"%}
  419. <div>
  420. {{ viewfilelink(patch.delta.new_file.path) }}<strike>{{patch.delta.old_file.path}}</strike>
  421. </div>
  422. <div class="d-flex align-items-center ml-auto">
  423. {{ changedlabel("file renamed", "info")}}
  424. {% if linesadded != 0 and linesremoved != 0%}
  425. {{ lineschanged(True, True) }}
  426. {% endif %}
  427. {{ viewfilelinkbutton(patch.delta.new_file.path) }}
  428. {% if linesadded != 0 and linesremoved != 0%}
  429. {{ diffcollapsebtn() }}
  430. {% endif %}
  431. </div>
  432. {%- endif -%}
  433. {%- endif -%}
  434. </div>
  435. </div>
  436. {% if patchtype == "moved" and linesadded == 0 and linesremoved == 0%}
  437. <div class="card-block">
  438. <div class="text-muted text-center my-4 font-weight-bold">file was renamed with no change to the file</div>
  439. </div>
  440. {% elif patchtype == "added" and linesadded == 0 %}
  441. <div class="card-block">
  442. <div class="text-muted text-center">empty file added</div>
  443. </div>
  444. {% else %}
  445. <div class="diff2html-output collapse show" data-diffno="{{loop.index}}" id="diff2html_{{loop.index}}"></div>
  446. {% endif %}
  447. </div>
  448. </section>
  449. {% endfor %}
  450. {% endif %}
  451. </div>
  452. </div>
  453. {% endblock %}
  454. {% block jscripts %}
  455. {{ super() }}
  456. <script type="text/javascript" nonce="{{ g.nonce }}" src="{{
  457. url_for('static', filename='vendor/diff2html/diff2html.min.js') }}?version={{ g.version}}"></script>
  458. <script type="text/javascript" nonce="{{ g.nonce }}" src="{{
  459. url_for('static', filename='vendor/highlight.js/highlight.pack.js') }}?version={{ g.version}}"></script>
  460. <script type="text/javascript" nonce="{{ g.nonce }}" src="{{
  461. url_for('static', filename='vendor/highlight.js/spec.js') }}?version={{ g.version}}"></script>
  462. <script type="text/javascript" nonce="{{ g.nonce }}" src="{{
  463. url_for('static', filename='vendor/diff2html/diff2html-ui.min.js') }}?version={{ g.version}}"></script>
  464. <script type="text/javascript" nonce="{{ g.nonce }}">
  465. $(document).ready(function() {
  466. $(".diffcollapse").click(function(e){
  467. $(this).find("i").toggleClass("fa-caret-down fa-caret-up")
  468. });
  469. });
  470. $(function(){
  471. $('#diff_list_link').click(function(){
  472. $('#diff_list').toggle();
  473. });
  474. });
  475. $.ajax({
  476. url: '{{ url_for("ui_ns.view_commit_diff", repo=repo.name,username=username,namespace=repo.namespace,commitid=commitid,js=True ) }}' ,
  477. type: 'GET',
  478. dataType: 'json',
  479. success: function(res) {
  480. $(".diff2html-output").each(function(){
  481. var diffString = res[$(this).attr("data-diffno")];
  482. var diff2htmlUi = new Diff2HtmlUI({diff: diffString});
  483. {% if splitview %}
  484. diff2htmlUi.draw('#diff2html_'+$(this).attr("data-diffno"), {inputFormat: 'diff', outputFormat: 'side-by-side'});
  485. {% else %}
  486. diff2htmlUi.draw('#diff2html_'+$(this).attr("data-diffno"), {inputFormat: 'diff'});
  487. {% endif %}
  488. diff2htmlUi.highlightCode('#diff2html_'+$(this).attr("data-diffno"));
  489. });
  490. }
  491. });
  492. $.ajax({
  493. url: '{{ url_for("internal_ns.get_branches_of_commit") }}' ,
  494. type: 'POST',
  495. data: {
  496. repo: "{{ repo.name }}",
  497. repouser: "{{ repo.user.user if repo.is_fork else '' }}",
  498. namespace: "{{ repo.namespace if repo.namespace else '' }}",
  499. commit_id: "{{ commitid }}",
  500. csrf_token: "{{ g.confirmationform.csrf_token.current_token }}",
  501. },
  502. dataType: 'json',
  503. success: function(res) {
  504. if (res.branches.length == 0){
  505. return;
  506. }
  507. var _br = '';
  508. for (var i = 0; i < res.branches.length; ++i) {
  509. if (_br.length > 0){
  510. _br += ', ';
  511. }
  512. _br += res.branches[i]
  513. }
  514. var el = $('#diff-file-1');
  515. if (!el){
  516. return;
  517. }
  518. el.before(
  519. '<div class=""><i class="fa fa-code-fork"></i> '
  520. + _br + '</div>');
  521. }
  522. });
  523. </script>
  524. {% endblock %}