You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

160 lines
6.6 KiB

9 years ago
Git LFS support v2 (#122) * Import github.com/git-lfs/lfs-test-server as lfs module base Imported commit is 3968aac269a77b73924649b9412ae03f7ccd3198 Removed: Dockerfile CONTRIBUTING.md mgmt* script/ vendor/ kvlogger.go .dockerignore .gitignore README.md * Remove config, add JWT support from github.com/mgit-at/lfs-test-server Imported commit f0cdcc5a01599c5a955dc1bbf683bb4acecdba83 * Add LFS settings * Add LFS meta object model * Add LFS routes and initialization * Import github.com/dgrijalva/jwt-go into vendor/ * Adapt LFS module: handlers, routing, meta store * Move LFS routes to /user/repo/info/lfs/* * Add request header checks to LFS BatchHandler / PostHandler * Implement LFS basic authentication * Rework JWT secret generation / load * Implement LFS SSH token authentication with JWT Specification: https://github.com/github/git-lfs/tree/master/docs/api * Integrate LFS settings into install process * Remove LFS objects when repository is deleted Only removes objects from content store when deleted repo is the only referencing repository * Make LFS module stateless Fixes bug where LFS would not work after installation without restarting Gitea * Change 500 'Internal Server Error' to 400 'Bad Request' * Change sql query to xorm call * Remove unneeded type from LFS module * Change internal imports to code.gitea.io/gitea/ * Add Gitea authors copyright * Change basic auth realm to "gitea-lfs" * Add unique indexes to LFS model * Use xorm count function in LFS check on repository delete * Return io.ReadCloser from content store and close after usage * Add LFS info to runWeb() * Export LFS content store base path * LFS file download from UI * Work around git-lfs client issue with unauthenticated requests Returning a dummy Authorization header for unauthenticated requests lets git-lfs client skip asking for auth credentials See: https://github.com/github/git-lfs/issues/1088 * Fix unauthenticated UI downloads from public repositories * Authentication check order, Finish LFS file view logic * Ignore LFS hooks if installed for current OS user Fixes Gitea UI actions for repositories tracking LFS files. Checks for minimum needed git version by parsing the semantic version string. * Hide LFS metafile diff from commit view, marking as binary * Show LFS notice if file in commit view is tracked * Add notbefore/nbf JWT claim * Correct lint suggestions - comments for structs and functions - Add comments to LFS model - Function comment for GetRandomBytesAsBase64 - LFS server function comments and lint variable suggestion * Move secret generation code out of conditional Ensures no LFS code may run with an empty secret * Do not hand out JWT tokens if LFS server support is disabled
8 years ago
Squashed commit of the following: commit 0afcb843d7ffd596991c4885cab768273a6eb42c Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 17:13:29 2016 -0600 Removed Upload stats as the upload table is just a temporary table commit 7ecd73ff5535612d79d471409173ee7f1fcfa157 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 08:42:41 2016 -0600 Fix for CodeMirror mode commit c29b9ab531e2e7af0fb5db24dc17e51027dd1174 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 08:03:33 2016 -0600 Made tabbing in editor use spaces commit 23af384c53206a8a40e11e45bf49d7a149c4adcd Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:56:46 2016 -0600 Fix for data-url commit cfb8a97591cb6fc0a92e49563b7b764c524db0e9 Merge: 7fc8a89 991ce42 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:42:53 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go public/js/gogs.js commit 7fc8a89cb495478225b02d613e647f99a1489634 Merge: fd3d86c c03d040 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:40:00 2016 -0600 Merge branch 'feature-create-and-edit-repo-file' of github.com:richmahn/gogs into feature-create-and-edit-repo-file commit fd3d86ca6bbc02cfda566a504ffd6b03db4f75ef Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:39:44 2016 -0600 Code cleanup commit c03d0401c1049eeeccc32ab1f9c3303c130be5ee Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 29 15:38:23 2016 -0600 Code cleanup commit 98e1206ccf9f9a4503c020e3a7830cf9f861dfae Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 18:36:01 2016 -0600 Code cleanup and fixes commit c2895dc742f25f8412879c9fa15e18f27f42f194 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 18:24:04 2016 -0600 Fixes per Unknwon's requests commit 6aa7e46b21ad4c96e562daa2eac26a8fb408f8ef Merge: 889e9fa ad7ea88 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 17:13:43 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go modules/setting/setting.go commit 889e9faf1bd8559a4979c8f46005d488c1a234d4 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:09:18 2016 -0600 Fix in gogs.js commit 47603edf223f147b114be65f3bd27bc1e88827a5 Merge: bb57912 cf85e9e Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:07:36 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go public/js/gogs.js commit bb5791255867a71c11a77b639db050ad09c597a4 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:02:18 2016 -0600 Update for using CodeMirror mode addon commit d10d128c51039be19e2af9c66c63db66a9f2ec6d Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Tue Jul 19 16:12:57 2016 -0600 Update for Edit commit 34a34982025144e3225e389f7849eb6273c1d576 Merge: fa1b752 1c7dcdd Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Tue Jul 19 11:52:02 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go commit fa1b752be29cd455c5184ddac2ffe80b3489763e Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 15 18:35:42 2016 -0600 Feature for editing, creating, uploading and deleting files
8 years ago
  1. {{if .DiffNotAvailable}}
  2. <h4>{{.i18n.Tr "repo.diff.data_not_available"}}</h4>
  3. {{else}}
  4. <div class="diff-detail-box diff-box">
  5. <div>
  6. <i class="fa fa-retweet"></i>
  7. {{.i18n.Tr "repo.diff.stats_desc" .Diff.NumFiles .Diff.TotalAddition .Diff.TotalDeletion | Str2html}}
  8. <div class="ui right">
  9. <a class="ui tiny basic toggle button" href="?style={{if .IsSplitStyle}}unified{{else}}split{{end}}">{{ if .IsSplitStyle }}{{.i18n.Tr "repo.diff.show_unified_view"}}{{else}}{{.i18n.Tr "repo.diff.show_split_view"}}{{end}}</a>
  10. <a class="ui tiny basic toggle button" data-target="#diff-files">{{.i18n.Tr "repo.diff.show_diff_stats"}}</a>
  11. </div>
  12. </div>
  13. <ol class="detail-files hide" id="diff-files">
  14. {{range .Diff.Files}}
  15. <li>
  16. <div class="diff-counter count pull-right">
  17. {{if not .IsBin}}
  18. <span class="add" data-line="{{.Addition}}">{{.Addition}}</span>
  19. <span class="bar">
  20. <div class="pull-left add"></div>
  21. <div class="pull-left del"></div>
  22. </span>
  23. <span class="del" data-line="{{.Deletion}}">{{.Deletion}}</span>
  24. {{else}}
  25. <span>{{$.i18n.Tr "repo.diff.bin"}}</span>
  26. {{end}}
  27. </div>
  28. <!-- todo finish all file status, now modify, add, delete and rename -->
  29. <span class="status {{DiffTypeToStr .GetType}} poping up" data-content="{{DiffTypeToStr .GetType}}" data-variation="inverted tiny" data-position="right center">&nbsp;</span>
  30. <a class="file" href="#diff-{{.Index}}">{{.Name}}</a>
  31. </li>
  32. {{end}}
  33. </ol>
  34. </div>
  35. {{range $i, $file := .Diff.Files}}
  36. {{if $file.IsIncomplete}}
  37. <div class="diff-file-box diff-box file-content">
  38. <h4 class="ui top attached normal header rounded">
  39. <div class="diff-counter count ui left">
  40. {{if not $file.IsRenamed}}
  41. <span class="add" data-line="{{.Addition}}">+ {{.Addition}}</span>
  42. <span class="bar">
  43. <div class="pull-left add"></div>
  44. <div class="pull-left del"></div>
  45. </span>
  46. <span class="del" data-line="{{.Deletion}}">- {{.Deletion}}</span>
  47. {{end}}
  48. </div>
  49. <span class="file">{{$file.Name}}</span>
  50. <div>{{$.i18n.Tr "repo.diff.file_suppressed"}}</div>
  51. {{if not $file.IsSubmodule}}
  52. {{if $file.IsDeleted}}
  53. <a class="ui basic grey tiny button" rel="nofollow" href="{{EscapePound $.BeforeSourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
  54. {{else}}
  55. <a class="ui basic grey tiny button" rel="nofollow" href="{{EscapePound $.SourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
  56. {{end}}
  57. {{end}}
  58. </h4>
  59. </div>
  60. {{else}}
  61. <div class="diff-file-box diff-box file-content {{TabSizeClass $.Editorconfig $file.Name}}" id="diff-{{.Index}}">
  62. <h4 class="ui top attached normal header">
  63. <div class="diff-counter count">
  64. {{if $file.IsBin}}
  65. {{$.i18n.Tr "repo.diff.bin"}}
  66. {{else if not $file.IsRenamed}}
  67. <span class="add" data-line="{{.Addition}}">+ {{.Addition}}</span>
  68. <span class="bar">
  69. <div class="pull-left add"></div>
  70. <div class="pull-left del"></div>
  71. </span>
  72. <span class="del" data-line="{{.Deletion}}">- {{.Deletion}}</span>
  73. {{end}}
  74. </div>
  75. <span class="file">{{if $file.IsRenamed}}{{$file.OldName}} &rarr; {{end}}{{$file.Name}}{{if .IsLFSFile}} ({{$.i18n.Tr "repo.stored_lfs"}}){{end}}</span>
  76. {{if not $file.IsSubmodule}}
  77. {{if $file.IsDeleted}}
  78. <a class="ui basic grey tiny button" rel="nofollow" href="{{EscapePound $.BeforeSourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
  79. {{else}}
  80. <a class="ui basic grey tiny button" rel="nofollow" href="{{EscapePound $.SourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
  81. {{end}}
  82. {{end}}
  83. </h4>
  84. <div class="ui attached unstackable table segment">
  85. {{if ne $file.Type 4}}
  86. {{$isImage := (call $.IsImageFile $file.Name)}}
  87. {{if and $isImage}}
  88. <div class="center">
  89. <img src="{{$.RawPath}}/{{EscapePound .Name}}">
  90. </div>
  91. {{else}}
  92. <div class="file-body file-code code-view code-diff {{if $.IsSplitStyle}}code-diff-split{{else}}code-diff-unified{{end}}">
  93. <table>
  94. <tbody>
  95. {{if $.IsSplitStyle}}
  96. {{$highlightClass := $file.GetHighlightClass}}
  97. {{range $j, $section := $file.Sections}}
  98. {{range $k, $line := $section.Lines}}
  99. <tr class="{{DiffLineTypeToStr .GetType}}-code nl-{{$k}} ol-{{$k}}">
  100. <td class="lines-num lines-num-old">
  101. <span rel="{{if $line.LeftIdx}}diff-{{Sha1 $file.Name}}L{{$line.LeftIdx}}{{end}}">{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}</span>
  102. </td>
  103. <td class="lines-code halfwidth">
  104. <pre><code class="wrap {{if $highlightClass}}language-{{$highlightClass}}{{else}}nohighlight{{end}}">{{if $line.LeftIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}</code></pre>
  105. </td>
  106. <td class="lines-num lines-num-new">
  107. <span rel="{{if $line.RightIdx}}diff-{{Sha1 $file.Name}}R{{$line.RightIdx}}{{end}}">{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}</span>
  108. </td>
  109. <td class="lines-code halfwidth">
  110. <pre><code class="wrap {{if $highlightClass}}language-{{$highlightClass}}{{else}}nohighlight{{end}}">{{if $line.RightIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}</code></pre>
  111. </td>
  112. </tr>
  113. {{end}}
  114. {{end}}
  115. {{else}}
  116. {{template "repo/diff/section_unified" .}}
  117. {{end}}
  118. </tbody>
  119. </table>
  120. </div>
  121. {{end}}
  122. {{end}}
  123. </div>
  124. </div>
  125. {{end}}
  126. <br>
  127. {{end}}
  128. {{if .Diff.IsIncomplete}}
  129. <div class="diff-file-box diff-box file-content">
  130. <h4 class="ui top attached normal header">
  131. {{$.i18n.Tr "repo.diff.too_many_files"}}
  132. </h4>
  133. </div>
  134. {{end}}
  135. {{if .IsSplitStyle}}
  136. <script>
  137. (function() {
  138. $('tr.add-code').each(function() {
  139. var prev = $(this).prev();
  140. if(prev.is('.del-code') && prev.children().eq(3).text().trim() === '') {
  141. while(prev.prev().is('.del-code') && prev.prev().children().eq(3).text().trim() === '') {
  142. prev = prev.prev();
  143. }
  144. prev.children().eq(2).html($(this).children().eq(2).html());
  145. prev.children().eq(3).html($(this).children().eq(3).html());
  146. prev.children().eq(0).addClass('del-code');
  147. prev.children().eq(1).addClass('del-code');
  148. prev.children().eq(2).addClass('add-code');
  149. prev.children().eq(3).addClass('add-code');
  150. $(this).remove();
  151. }
  152. });
  153. }());
  154. </script>
  155. {{end}}
  156. {{end}}