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

repo.go 67 kB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
10 years ago
11 years ago
9 years ago
10 years ago
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
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
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
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
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
11 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
11 years ago
9 years ago
9 years ago
9 years ago
11 years ago
9 years ago
11 years ago
9 years ago
9 years ago
9 years ago
9 years ago
11 years ago
9 years ago
9 years ago
9 years ago
9 years ago
11 years ago
9 years ago
10 years ago
10 years ago
9 years ago
9 years ago
9 years ago
9 years ago
11 years ago
11 years ago
9 years ago
9 years ago
9 years ago
11 years ago
11 years ago
11 years ago
11 years ago
10 years ago
10 years ago
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
11 years ago
11 years ago
11 years ago
11 years ago
9 years ago
9 years ago
11 years ago
9 years ago
10 years ago
10 years ago
9 years ago
10 years ago
8 years ago
8 years ago
10 years ago
10 years ago
10 years ago
10 years ago
8 years ago
8 years ago
11 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
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
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
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
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
9 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
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
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
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
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
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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274
  1. // Copyright 2014 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package models
  5. import (
  6. "bytes"
  7. "errors"
  8. "fmt"
  9. "html/template"
  10. "io/ioutil"
  11. "os"
  12. "os/exec"
  13. "path"
  14. "path/filepath"
  15. "regexp"
  16. "sort"
  17. "strings"
  18. "time"
  19. "code.gitea.io/git"
  20. "code.gitea.io/gitea/modules/log"
  21. "code.gitea.io/gitea/modules/markdown"
  22. "code.gitea.io/gitea/modules/options"
  23. "code.gitea.io/gitea/modules/process"
  24. "code.gitea.io/gitea/modules/setting"
  25. "code.gitea.io/gitea/modules/sync"
  26. api "code.gitea.io/sdk/gitea"
  27. "github.com/Unknwon/cae/zip"
  28. "github.com/Unknwon/com"
  29. "github.com/go-xorm/xorm"
  30. version "github.com/mcuadros/go-version"
  31. ini "gopkg.in/ini.v1"
  32. )
  33. const (
  34. tplUpdateHook = "#!/usr/bin/env %s\n%s update $1 $2 $3 --config='%s'\n"
  35. )
  36. var repoWorkingPool = sync.NewExclusivePool()
  37. var (
  38. // ErrRepoFileNotExist repository file does not exist error
  39. ErrRepoFileNotExist = errors.New("Repository file does not exist")
  40. // ErrRepoFileNotLoaded repository file not loaded error
  41. ErrRepoFileNotLoaded = errors.New("Repository file not loaded")
  42. // ErrMirrorNotExist mirror does not exist error
  43. ErrMirrorNotExist = errors.New("Mirror does not exist")
  44. // ErrInvalidReference invalid reference specified error
  45. ErrInvalidReference = errors.New("Invalid reference specified")
  46. // ErrNameEmpty name is empty error
  47. ErrNameEmpty = errors.New("Name is empty")
  48. )
  49. var (
  50. // Gitignores contains the gitiginore files
  51. Gitignores []string
  52. // Licenses contains the license files
  53. Licenses []string
  54. // Readmes contains the readme files
  55. Readmes []string
  56. // LabelTemplates contains the label template files
  57. LabelTemplates []string
  58. // ItemsPerPage maximum items per page in forks, watchers and stars of a repo
  59. ItemsPerPage = 40
  60. )
  61. // LoadRepoConfig loads the repository config
  62. func LoadRepoConfig() {
  63. // Load .gitignore and license files and readme templates.
  64. types := []string{"gitignore", "license", "readme", "label"}
  65. typeFiles := make([][]string, 4)
  66. for i, t := range types {
  67. files, err := options.Dir(t)
  68. if err != nil {
  69. log.Fatal(4, "Failed to get %s files: %v", t, err)
  70. }
  71. customPath := path.Join(setting.CustomPath, "options", t)
  72. if com.IsDir(customPath) {
  73. customFiles, err := com.StatDir(customPath)
  74. if err != nil {
  75. log.Fatal(4, "Failed to get custom %s files: %v", t, err)
  76. }
  77. for _, f := range customFiles {
  78. if !com.IsSliceContainsStr(files, f) {
  79. files = append(files, f)
  80. }
  81. }
  82. }
  83. typeFiles[i] = files
  84. }
  85. Gitignores = typeFiles[0]
  86. Licenses = typeFiles[1]
  87. Readmes = typeFiles[2]
  88. LabelTemplates = typeFiles[3]
  89. sort.Strings(Gitignores)
  90. sort.Strings(Licenses)
  91. sort.Strings(Readmes)
  92. sort.Strings(LabelTemplates)
  93. // Filter out invalid names and promote preferred licenses.
  94. sortedLicenses := make([]string, 0, len(Licenses))
  95. for _, name := range setting.Repository.PreferredLicenses {
  96. if com.IsSliceContainsStr(Licenses, name) {
  97. sortedLicenses = append(sortedLicenses, name)
  98. }
  99. }
  100. for _, name := range Licenses {
  101. if !com.IsSliceContainsStr(setting.Repository.PreferredLicenses, name) {
  102. sortedLicenses = append(sortedLicenses, name)
  103. }
  104. }
  105. Licenses = sortedLicenses
  106. }
  107. // NewRepoContext creates a new repository context
  108. func NewRepoContext() {
  109. zip.Verbose = false
  110. // Check Git installation.
  111. if _, err := exec.LookPath("git"); err != nil {
  112. log.Fatal(4, "Failed to test 'git' command: %v (forgotten install?)", err)
  113. }
  114. // Check Git version.
  115. var err error
  116. setting.Git.Version, err = git.BinVersion()
  117. if err != nil {
  118. log.Fatal(4, "Failed to get Git version: %v", err)
  119. }
  120. log.Info("Git Version: %s", setting.Git.Version)
  121. if version.Compare("1.7.1", setting.Git.Version, ">") {
  122. log.Fatal(4, "Gitea requires Git version greater or equal to 1.7.1")
  123. }
  124. // Git requires setting user.name and user.email in order to commit changes.
  125. for configKey, defaultValue := range map[string]string{"user.name": "Gitea", "user.email": "gitea@fake.local"} {
  126. if stdout, stderr, err := process.GetManager().Exec("NewRepoContext(get setting)", "git", "config", "--get", configKey); err != nil || strings.TrimSpace(stdout) == "" {
  127. // ExitError indicates this config is not set
  128. if _, ok := err.(*exec.ExitError); ok || strings.TrimSpace(stdout) == "" {
  129. if _, stderr, gerr := process.GetManager().Exec("NewRepoContext(set "+configKey+")", "git", "config", "--global", configKey, defaultValue); gerr != nil {
  130. log.Fatal(4, "Failed to set git %s(%s): %s", configKey, gerr, stderr)
  131. }
  132. log.Info("Git config %s set to %s", configKey, defaultValue)
  133. } else {
  134. log.Fatal(4, "Failed to get git %s(%s): %s", configKey, err, stderr)
  135. }
  136. }
  137. }
  138. // Set git some configurations.
  139. if _, stderr, err := process.GetManager().Exec("NewRepoContext(git config --global core.quotepath false)",
  140. "git", "config", "--global", "core.quotepath", "false"); err != nil {
  141. log.Fatal(4, "Failed to execute 'git config --global core.quotepath false': %s", stderr)
  142. }
  143. RemoveAllWithNotice("Clean up repository temporary data", filepath.Join(setting.AppDataPath, "tmp"))
  144. }
  145. // Repository represents a git repository.
  146. type Repository struct {
  147. ID int64 `xorm:"pk autoincr"`
  148. OwnerID int64 `xorm:"UNIQUE(s)"`
  149. Owner *User `xorm:"-"`
  150. LowerName string `xorm:"UNIQUE(s) INDEX NOT NULL"`
  151. Name string `xorm:"INDEX NOT NULL"`
  152. Description string
  153. Website string
  154. DefaultBranch string
  155. NumWatches int
  156. NumStars int
  157. NumForks int
  158. NumIssues int
  159. NumClosedIssues int
  160. NumOpenIssues int `xorm:"-"`
  161. NumPulls int
  162. NumClosedPulls int
  163. NumOpenPulls int `xorm:"-"`
  164. NumMilestones int `xorm:"NOT NULL DEFAULT 0"`
  165. NumClosedMilestones int `xorm:"NOT NULL DEFAULT 0"`
  166. NumOpenMilestones int `xorm:"-"`
  167. NumTags int `xorm:"-"`
  168. IsPrivate bool `xorm:"INDEX"`
  169. IsBare bool `xorm:"INDEX"`
  170. IsMirror bool `xorm:"INDEX"`
  171. *Mirror `xorm:"-"`
  172. ExternalMetas map[string]string `xorm:"-"`
  173. Units []*RepoUnit `xorm:"-"`
  174. IsFork bool `xorm:"INDEX NOT NULL DEFAULT false"`
  175. ForkID int64 `xorm:"INDEX"`
  176. BaseRepo *Repository `xorm:"-"`
  177. Size int64 `xorm:"NOT NULL DEFAULT 0"`
  178. Created time.Time `xorm:"-"`
  179. CreatedUnix int64 `xorm:"INDEX"`
  180. Updated time.Time `xorm:"-"`
  181. UpdatedUnix int64 `xorm:"INDEX"`
  182. }
  183. // BeforeInsert is invoked from XORM before inserting an object of this type.
  184. func (repo *Repository) BeforeInsert() {
  185. repo.CreatedUnix = time.Now().Unix()
  186. repo.UpdatedUnix = repo.CreatedUnix
  187. }
  188. // BeforeUpdate is invoked from XORM before updating this object.
  189. func (repo *Repository) BeforeUpdate() {
  190. repo.UpdatedUnix = time.Now().Unix()
  191. }
  192. // AfterSet is invoked from XORM after setting the value of a field of this object.
  193. func (repo *Repository) AfterSet(colName string, _ xorm.Cell) {
  194. switch colName {
  195. case "default_branch":
  196. // FIXME: use models migration to solve all at once.
  197. if len(repo.DefaultBranch) == 0 {
  198. repo.DefaultBranch = "master"
  199. }
  200. case "num_closed_issues":
  201. repo.NumOpenIssues = repo.NumIssues - repo.NumClosedIssues
  202. case "num_closed_pulls":
  203. repo.NumOpenPulls = repo.NumPulls - repo.NumClosedPulls
  204. case "num_closed_milestones":
  205. repo.NumOpenMilestones = repo.NumMilestones - repo.NumClosedMilestones
  206. case "created_unix":
  207. repo.Created = time.Unix(repo.CreatedUnix, 0).Local()
  208. case "updated_unix":
  209. repo.Updated = time.Unix(repo.UpdatedUnix, 0)
  210. }
  211. }
  212. // MustOwner always returns a valid *User object to avoid
  213. // conceptually impossible error handling.
  214. // It creates a fake object that contains error details
  215. // when error occurs.
  216. func (repo *Repository) MustOwner() *User {
  217. return repo.mustOwner(x)
  218. }
  219. // FullName returns the repository full name
  220. func (repo *Repository) FullName() string {
  221. return repo.MustOwner().Name + "/" + repo.Name
  222. }
  223. // HTMLURL returns the repository HTML URL
  224. func (repo *Repository) HTMLURL() string {
  225. return setting.AppURL + repo.FullName()
  226. }
  227. // APIURL returns the repository API URL
  228. func (repo *Repository) APIURL() string {
  229. return setting.AppURL + path.Join("api/v1/repos", repo.FullName())
  230. }
  231. // APIFormat converts a Repository to api.Repository
  232. func (repo *Repository) APIFormat(mode AccessMode) *api.Repository {
  233. cloneLink := repo.CloneLink()
  234. permission := &api.Permission{
  235. Admin: mode >= AccessModeAdmin,
  236. Push: mode >= AccessModeWrite,
  237. Pull: mode >= AccessModeRead,
  238. }
  239. return &api.Repository{
  240. ID: repo.ID,
  241. Owner: repo.Owner.APIFormat(),
  242. Name: repo.Name,
  243. FullName: repo.FullName(),
  244. Description: repo.Description,
  245. Private: repo.IsPrivate,
  246. Empty: repo.IsBare,
  247. Size: int(repo.Size/1024),
  248. Fork: repo.IsFork,
  249. Mirror: repo.IsMirror,
  250. HTMLURL: repo.HTMLURL(),
  251. SSHURL: cloneLink.SSH,
  252. CloneURL: cloneLink.HTTPS,
  253. Website: repo.Website,
  254. Stars: repo.NumStars,
  255. Forks: repo.NumForks,
  256. Watchers: repo.NumWatches,
  257. OpenIssues: repo.NumOpenIssues,
  258. DefaultBranch: repo.DefaultBranch,
  259. Created: repo.Created,
  260. Updated: repo.Updated,
  261. Permissions: permission,
  262. }
  263. }
  264. func (repo *Repository) getUnits(e Engine) (err error) {
  265. if repo.Units != nil {
  266. return nil
  267. }
  268. repo.Units, err = getUnitsByRepoID(e, repo.ID)
  269. return err
  270. }
  271. func getUnitsByRepoID(e Engine, repoID int64) (units []*RepoUnit, err error) {
  272. return units, e.Where("repo_id = ?", repoID).Find(&units)
  273. }
  274. // EnableUnit if this repository enabled some unit
  275. func (repo *Repository) EnableUnit(tp UnitType) bool {
  276. repo.getUnits(x)
  277. for _, unit := range repo.Units {
  278. if unit.Type == tp {
  279. return true
  280. }
  281. }
  282. return false
  283. }
  284. var (
  285. // ErrUnitNotExist organization does not exist
  286. ErrUnitNotExist = errors.New("Unit does not exist")
  287. )
  288. // MustGetUnit always returns a RepoUnit object
  289. func (repo *Repository) MustGetUnit(tp UnitType) *RepoUnit {
  290. ru, err := repo.GetUnit(tp)
  291. if err == nil {
  292. return ru
  293. }
  294. if tp == UnitTypeExternalWiki {
  295. return &RepoUnit{
  296. Type: tp,
  297. Config: new(ExternalWikiConfig),
  298. }
  299. } else if tp == UnitTypeExternalTracker {
  300. return &RepoUnit{
  301. Type: tp,
  302. Config: new(ExternalTrackerConfig),
  303. }
  304. }
  305. return &RepoUnit{
  306. Type: tp,
  307. Config: new(UnitConfig),
  308. }
  309. }
  310. // GetUnit returns a RepoUnit object
  311. func (repo *Repository) GetUnit(tp UnitType) (*RepoUnit, error) {
  312. if err := repo.getUnits(x); err != nil {
  313. return nil, err
  314. }
  315. for _, unit := range repo.Units {
  316. if unit.Type == tp {
  317. return unit, nil
  318. }
  319. }
  320. return nil, ErrUnitNotExist
  321. }
  322. func (repo *Repository) getOwner(e Engine) (err error) {
  323. if repo.Owner != nil {
  324. return nil
  325. }
  326. repo.Owner, err = getUserByID(e, repo.OwnerID)
  327. return err
  328. }
  329. // GetOwner returns the repository owner
  330. func (repo *Repository) GetOwner() error {
  331. return repo.getOwner(x)
  332. }
  333. func (repo *Repository) mustOwner(e Engine) *User {
  334. if err := repo.getOwner(e); err != nil {
  335. return &User{
  336. Name: "error",
  337. FullName: err.Error(),
  338. }
  339. }
  340. return repo.Owner
  341. }
  342. // ComposeMetas composes a map of metas for rendering external issue tracker URL.
  343. func (repo *Repository) ComposeMetas() map[string]string {
  344. unit, err := repo.GetUnit(UnitTypeExternalTracker)
  345. if err != nil {
  346. return nil
  347. }
  348. if repo.ExternalMetas == nil {
  349. repo.ExternalMetas = map[string]string{
  350. "format": unit.ExternalTrackerConfig().ExternalTrackerFormat,
  351. "user": repo.MustOwner().Name,
  352. "repo": repo.Name,
  353. }
  354. switch unit.ExternalTrackerConfig().ExternalTrackerStyle {
  355. case markdown.IssueNameStyleAlphanumeric:
  356. repo.ExternalMetas["style"] = markdown.IssueNameStyleAlphanumeric
  357. default:
  358. repo.ExternalMetas["style"] = markdown.IssueNameStyleNumeric
  359. }
  360. }
  361. return repo.ExternalMetas
  362. }
  363. // DeleteWiki removes the actual and local copy of repository wiki.
  364. func (repo *Repository) DeleteWiki() error {
  365. return repo.deleteWiki(x)
  366. }
  367. func (repo *Repository) deleteWiki(e Engine) error {
  368. wikiPaths := []string{repo.WikiPath(), repo.LocalWikiPath()}
  369. for _, wikiPath := range wikiPaths {
  370. removeAllWithNotice(e, "Delete repository wiki", wikiPath)
  371. }
  372. _, err := e.Where("repo_id = ?", repo.ID).And("type = ?", UnitTypeWiki).Delete(new(RepoUnit))
  373. return err
  374. }
  375. func (repo *Repository) getAssignees(e Engine) (_ []*User, err error) {
  376. if err = repo.getOwner(e); err != nil {
  377. return nil, err
  378. }
  379. accesses := make([]*Access, 0, 10)
  380. if err = e.
  381. Where("repo_id = ? AND mode >= ?", repo.ID, AccessModeWrite).
  382. Find(&accesses); err != nil {
  383. return nil, err
  384. }
  385. // Leave a seat for owner itself to append later, but if owner is an organization
  386. // and just waste 1 unit is cheaper than re-allocate memory once.
  387. users := make([]*User, 0, len(accesses)+1)
  388. if len(accesses) > 0 {
  389. userIDs := make([]int64, len(accesses))
  390. for i := 0; i < len(accesses); i++ {
  391. userIDs[i] = accesses[i].UserID
  392. }
  393. if err = e.In("id", userIDs).Find(&users); err != nil {
  394. return nil, err
  395. }
  396. }
  397. if !repo.Owner.IsOrganization() {
  398. users = append(users, repo.Owner)
  399. }
  400. return users, nil
  401. }
  402. // GetAssignees returns all users that have write access and can be assigned to issues
  403. // of the repository,
  404. func (repo *Repository) GetAssignees() (_ []*User, err error) {
  405. return repo.getAssignees(x)
  406. }
  407. // GetAssigneeByID returns the user that has write access of repository by given ID.
  408. func (repo *Repository) GetAssigneeByID(userID int64) (*User, error) {
  409. return GetAssigneeByID(repo, userID)
  410. }
  411. // GetMilestoneByID returns the milestone belongs to repository by given ID.
  412. func (repo *Repository) GetMilestoneByID(milestoneID int64) (*Milestone, error) {
  413. return GetMilestoneByRepoID(repo.ID, milestoneID)
  414. }
  415. // IssueStats returns number of open and closed repository issues by given filter mode.
  416. func (repo *Repository) IssueStats(uid int64, filterMode int, isPull bool) (int64, int64) {
  417. return GetRepoIssueStats(repo.ID, uid, filterMode, isPull)
  418. }
  419. // GetMirror sets the repository mirror, returns an error upon failure
  420. func (repo *Repository) GetMirror() (err error) {
  421. repo.Mirror, err = GetMirrorByRepoID(repo.ID)
  422. return err
  423. }
  424. // GetBaseRepo returns the base repository
  425. func (repo *Repository) GetBaseRepo() (err error) {
  426. if !repo.IsFork {
  427. return nil
  428. }
  429. repo.BaseRepo, err = GetRepositoryByID(repo.ForkID)
  430. return err
  431. }
  432. func (repo *Repository) repoPath(e Engine) string {
  433. return RepoPath(repo.mustOwner(e).Name, repo.Name)
  434. }
  435. // RepoPath returns the repository path
  436. func (repo *Repository) RepoPath() string {
  437. return repo.repoPath(x)
  438. }
  439. // GitConfigPath returns the repository git config path
  440. func (repo *Repository) GitConfigPath() string {
  441. return filepath.Join(repo.RepoPath(), "config")
  442. }
  443. // RelLink returns the repository relative link
  444. func (repo *Repository) RelLink() string {
  445. return "/" + repo.FullName()
  446. }
  447. // Link returns the repository link
  448. func (repo *Repository) Link() string {
  449. return setting.AppSubURL + "/" + repo.FullName()
  450. }
  451. // ComposeCompareURL returns the repository comparison URL
  452. func (repo *Repository) ComposeCompareURL(oldCommitID, newCommitID string) string {
  453. return fmt.Sprintf("%s/%s/compare/%s...%s", repo.MustOwner().Name, repo.Name, oldCommitID, newCommitID)
  454. }
  455. // HasAccess returns true when user has access to this repository
  456. func (repo *Repository) HasAccess(u *User) bool {
  457. has, _ := HasAccess(u.ID, repo, AccessModeRead)
  458. return has
  459. }
  460. // UpdateDefaultBranch updates the default branch
  461. func (repo *Repository) UpdateDefaultBranch() error {
  462. _, err := x.ID(repo.ID).Cols("default_branch").Update(repo)
  463. return err
  464. }
  465. // IsOwnedBy returns true when user owns this repository
  466. func (repo *Repository) IsOwnedBy(userID int64) bool {
  467. return repo.OwnerID == userID
  468. }
  469. // UpdateSize updates the repository size, calculating it using git.GetRepoSize
  470. func (repo *Repository) UpdateSize() error {
  471. repoInfoSize, err := git.GetRepoSize(repo.RepoPath())
  472. if err != nil {
  473. return fmt.Errorf("UpdateSize: %v", err)
  474. }
  475. repo.Size = repoInfoSize.Size + repoInfoSize.SizePack
  476. _, err = x.ID(repo.ID).Cols("size").Update(repo)
  477. return err
  478. }
  479. // CanBeForked returns true if repository meets the requirements of being forked.
  480. func (repo *Repository) CanBeForked() bool {
  481. return !repo.IsBare
  482. }
  483. // CanEnablePulls returns true if repository meets the requirements of accepting pulls.
  484. func (repo *Repository) CanEnablePulls() bool {
  485. return !repo.IsMirror && !repo.IsBare
  486. }
  487. // AllowsPulls returns true if repository meets the requirements of accepting pulls and has them enabled.
  488. func (repo *Repository) AllowsPulls() bool {
  489. return repo.CanEnablePulls() && repo.EnableUnit(UnitTypePullRequests)
  490. }
  491. // CanEnableEditor returns true if repository meets the requirements of web editor.
  492. func (repo *Repository) CanEnableEditor() bool {
  493. return !repo.IsMirror
  494. }
  495. // NextIssueIndex returns the next issue index
  496. // FIXME: should have a mutex to prevent producing same index for two issues that are created
  497. // closely enough.
  498. func (repo *Repository) NextIssueIndex() int64 {
  499. return int64(repo.NumIssues+repo.NumPulls) + 1
  500. }
  501. var (
  502. descPattern = regexp.MustCompile(`https?://\S+`)
  503. )
  504. // DescriptionHTML does special handles to description and return HTML string.
  505. func (repo *Repository) DescriptionHTML() template.HTML {
  506. sanitize := func(s string) string {
  507. return fmt.Sprintf(`<a href="%[1]s" target="_blank" rel="noopener">%[1]s</a>`, s)
  508. }
  509. return template.HTML(descPattern.ReplaceAllStringFunc(markdown.Sanitize(repo.Description), sanitize))
  510. }
  511. // LocalCopyPath returns the local repository copy path
  512. func (repo *Repository) LocalCopyPath() string {
  513. return path.Join(setting.AppDataPath, "tmp/local-repo", com.ToStr(repo.ID))
  514. }
  515. // UpdateLocalCopyBranch pulls latest changes of given branch from repoPath to localPath.
  516. // It creates a new clone if local copy does not exist.
  517. // This function checks out target branch by default, it is safe to assume subsequent
  518. // operations are operating against target branch when caller has confidence for no race condition.
  519. func UpdateLocalCopyBranch(repoPath, localPath, branch string) error {
  520. if !com.IsExist(localPath) {
  521. if err := git.Clone(repoPath, localPath, git.CloneRepoOptions{
  522. Timeout: time.Duration(setting.Git.Timeout.Clone) * time.Second,
  523. Branch: branch,
  524. }); err != nil {
  525. return fmt.Errorf("git clone %s: %v", branch, err)
  526. }
  527. } else {
  528. if err := git.Checkout(localPath, git.CheckoutOptions{
  529. Branch: branch,
  530. }); err != nil {
  531. return fmt.Errorf("git checkout %s: %v", branch, err)
  532. }
  533. if err := git.Pull(localPath, git.PullRemoteOptions{
  534. Timeout: time.Duration(setting.Git.Timeout.Pull) * time.Second,
  535. Remote: "origin",
  536. Branch: branch,
  537. }); err != nil {
  538. return fmt.Errorf("git pull origin %s: %v", branch, err)
  539. }
  540. }
  541. return nil
  542. }
  543. // UpdateLocalCopyBranch makes sure local copy of repository in given branch is up-to-date.
  544. func (repo *Repository) UpdateLocalCopyBranch(branch string) error {
  545. return UpdateLocalCopyBranch(repo.RepoPath(), repo.LocalCopyPath(), branch)
  546. }
  547. // PatchPath returns corresponding patch file path of repository by given issue ID.
  548. func (repo *Repository) PatchPath(index int64) (string, error) {
  549. if err := repo.GetOwner(); err != nil {
  550. return "", err
  551. }
  552. return filepath.Join(RepoPath(repo.Owner.Name, repo.Name), "pulls", com.ToStr(index)+".patch"), nil
  553. }
  554. // SavePatch saves patch data to corresponding location by given issue ID.
  555. func (repo *Repository) SavePatch(index int64, patch []byte) error {
  556. patchPath, err := repo.PatchPath(index)
  557. if err != nil {
  558. return fmt.Errorf("PatchPath: %v", err)
  559. }
  560. dir := filepath.Dir(patchPath)
  561. if err := os.MkdirAll(dir, os.ModePerm); err != nil {
  562. return fmt.Errorf("Failed to create dir %s: %v", dir, err)
  563. }
  564. if err = ioutil.WriteFile(patchPath, patch, 0644); err != nil {
  565. return fmt.Errorf("WriteFile: %v", err)
  566. }
  567. return nil
  568. }
  569. func isRepositoryExist(e Engine, u *User, repoName string) (bool, error) {
  570. has, err := e.Get(&Repository{
  571. OwnerID: u.ID,
  572. LowerName: strings.ToLower(repoName),
  573. })
  574. return has && com.IsDir(RepoPath(u.Name, repoName)), err
  575. }
  576. // IsRepositoryExist returns true if the repository with given name under user has already existed.
  577. func IsRepositoryExist(u *User, repoName string) (bool, error) {
  578. return isRepositoryExist(x, u, repoName)
  579. }
  580. // CloneLink represents different types of clone URLs of repository.
  581. type CloneLink struct {
  582. SSH string
  583. HTTPS string
  584. Git string
  585. }
  586. // ComposeHTTPSCloneURL returns HTTPS clone URL based on given owner and repository name.
  587. func ComposeHTTPSCloneURL(owner, repo string) string {
  588. return fmt.Sprintf("%s%s/%s.git", setting.AppURL, owner, repo)
  589. }
  590. func (repo *Repository) cloneLink(isWiki bool) *CloneLink {
  591. repoName := repo.Name
  592. if isWiki {
  593. repoName += ".wiki"
  594. }
  595. repo.Owner = repo.MustOwner()
  596. cl := new(CloneLink)
  597. if setting.SSH.Port != 22 {
  598. cl.SSH = fmt.Sprintf("ssh://%s@%s:%d/%s/%s.git", setting.RunUser, setting.SSH.Domain, setting.SSH.Port, repo.Owner.Name, repoName)
  599. } else {
  600. cl.SSH = fmt.Sprintf("%s@%s:%s/%s.git", setting.RunUser, setting.SSH.Domain, repo.Owner.Name, repoName)
  601. }
  602. cl.HTTPS = ComposeHTTPSCloneURL(repo.Owner.Name, repoName)
  603. return cl
  604. }
  605. // CloneLink returns clone URLs of repository.
  606. func (repo *Repository) CloneLink() (cl *CloneLink) {
  607. return repo.cloneLink(false)
  608. }
  609. // MigrateRepoOptions contains the repository migrate options
  610. type MigrateRepoOptions struct {
  611. Name string
  612. Description string
  613. IsPrivate bool
  614. IsMirror bool
  615. RemoteAddr string
  616. }
  617. /*
  618. GitHub, GitLab, Gogs: *.wiki.git
  619. BitBucket: *.git/wiki
  620. */
  621. var commonWikiURLSuffixes = []string{".wiki.git", ".git/wiki"}
  622. // wikiRemoteURL returns accessible repository URL for wiki if exists.
  623. // Otherwise, it returns an empty string.
  624. func wikiRemoteURL(remote string) string {
  625. remote = strings.TrimSuffix(remote, ".git")
  626. for _, suffix := range commonWikiURLSuffixes {
  627. wikiURL := remote + suffix
  628. if git.IsRepoURLAccessible(wikiURL) {
  629. return wikiURL
  630. }
  631. }
  632. return ""
  633. }
  634. // MigrateRepository migrates a existing repository from other project hosting.
  635. func MigrateRepository(u *User, opts MigrateRepoOptions) (*Repository, error) {
  636. repo, err := CreateRepository(u, CreateRepoOptions{
  637. Name: opts.Name,
  638. Description: opts.Description,
  639. IsPrivate: opts.IsPrivate,
  640. IsMirror: opts.IsMirror,
  641. })
  642. if err != nil {
  643. return nil, err
  644. }
  645. repoPath := RepoPath(u.Name, opts.Name)
  646. wikiPath := WikiPath(u.Name, opts.Name)
  647. if u.IsOrganization() {
  648. t, err := u.GetOwnerTeam()
  649. if err != nil {
  650. return nil, err
  651. }
  652. repo.NumWatches = t.NumMembers
  653. } else {
  654. repo.NumWatches = 1
  655. }
  656. migrateTimeout := time.Duration(setting.Git.Timeout.Migrate) * time.Second
  657. if err := os.RemoveAll(repoPath); err != nil {
  658. return repo, fmt.Errorf("Failed to remove %s: %v", repoPath, err)
  659. }
  660. if err = git.Clone(opts.RemoteAddr, repoPath, git.CloneRepoOptions{
  661. Mirror: true,
  662. Quiet: true,
  663. Timeout: migrateTimeout,
  664. }); err != nil {
  665. return repo, fmt.Errorf("Clone: %v", err)
  666. }
  667. wikiRemotePath := wikiRemoteURL(opts.RemoteAddr)
  668. if len(wikiRemotePath) > 0 {
  669. if err := os.RemoveAll(wikiPath); err != nil {
  670. return repo, fmt.Errorf("Failed to remove %s: %v", wikiPath, err)
  671. }
  672. if err = git.Clone(wikiRemotePath, wikiPath, git.CloneRepoOptions{
  673. Mirror: true,
  674. Quiet: true,
  675. Timeout: migrateTimeout,
  676. Branch: "master",
  677. }); err != nil {
  678. log.Warn("Clone wiki: %v", err)
  679. if err := os.RemoveAll(wikiPath); err != nil {
  680. return repo, fmt.Errorf("Failed to remove %s: %v", wikiPath, err)
  681. }
  682. }
  683. }
  684. // Check if repository is empty.
  685. _, stderr, err := com.ExecCmdDir(repoPath, "git", "log", "-1")
  686. if err != nil {
  687. if strings.Contains(stderr, "fatal: bad default revision 'HEAD'") {
  688. repo.IsBare = true
  689. } else {
  690. return repo, fmt.Errorf("check bare: %v - %s", err, stderr)
  691. }
  692. }
  693. if !repo.IsBare {
  694. // Try to get HEAD branch and set it as default branch.
  695. gitRepo, err := git.OpenRepository(repoPath)
  696. if err != nil {
  697. return repo, fmt.Errorf("OpenRepository: %v", err)
  698. }
  699. headBranch, err := gitRepo.GetHEADBranch()
  700. if err != nil {
  701. return repo, fmt.Errorf("GetHEADBranch: %v", err)
  702. }
  703. if headBranch != nil {
  704. repo.DefaultBranch = headBranch.Name
  705. }
  706. }
  707. if err = repo.UpdateSize(); err != nil {
  708. log.Error(4, "Failed to update size for repository: %v", err)
  709. }
  710. if opts.IsMirror {
  711. if _, err = x.InsertOne(&Mirror{
  712. RepoID: repo.ID,
  713. Interval: setting.Mirror.DefaultInterval,
  714. EnablePrune: true,
  715. NextUpdate: time.Now().Add(setting.Mirror.DefaultInterval),
  716. }); err != nil {
  717. return repo, fmt.Errorf("InsertOne: %v", err)
  718. }
  719. repo.IsMirror = true
  720. return repo, UpdateRepository(repo, false)
  721. }
  722. return CleanUpMigrateInfo(repo)
  723. }
  724. // cleanUpMigrateGitConfig removes mirror info which prevents "push --all".
  725. // This also removes possible user credentials.
  726. func cleanUpMigrateGitConfig(configPath string) error {
  727. cfg, err := ini.Load(configPath)
  728. if err != nil {
  729. return fmt.Errorf("open config file: %v", err)
  730. }
  731. cfg.DeleteSection("remote \"origin\"")
  732. if err = cfg.SaveToIndent(configPath, "\t"); err != nil {
  733. return fmt.Errorf("save config file: %v", err)
  734. }
  735. return nil
  736. }
  737. // createDelegateHooks creates all the hooks scripts for the repo
  738. func createDelegateHooks(repoPath string) (err error) {
  739. var (
  740. hookNames = []string{"pre-receive", "update", "post-receive"}
  741. hookTpl = fmt.Sprintf("#!/usr/bin/env %s\ndata=$(cat)\nexitcodes=\"\"\nhookname=$(basename $0)\nGIT_DIR=${GIT_DIR:-$(dirname $0)}\n\nfor hook in ${GIT_DIR}/hooks/${hookname}.d/*; do\ntest -x \"${hook}\" || continue\necho \"${data}\" | \"${hook}\"\nexitcodes=\"${exitcodes} $?\"\ndone\n\nfor i in ${exitcodes}; do\n[ ${i} -eq 0 ] || exit ${i}\ndone\n", setting.ScriptType)
  742. giteaHookTpls = []string{
  743. fmt.Sprintf("#!/usr/bin/env %s\n\"%s\" hook --config='%s' pre-receive\n", setting.ScriptType, setting.AppPath, setting.CustomConf),
  744. fmt.Sprintf("#!/usr/bin/env %s\n\"%s\" hook --config='%s' update $1 $2 $3\n", setting.ScriptType, setting.AppPath, setting.CustomConf),
  745. fmt.Sprintf("#!/usr/bin/env %s\n\"%s\" hook --config='%s' post-receive\n", setting.ScriptType, setting.AppPath, setting.CustomConf),
  746. }
  747. )
  748. hookDir := filepath.Join(repoPath, "hooks")
  749. for i, hookName := range hookNames {
  750. oldHookPath := filepath.Join(hookDir, hookName)
  751. newHookPath := filepath.Join(hookDir, hookName+".d", "gitea")
  752. if err := os.MkdirAll(filepath.Join(hookDir, hookName+".d"), os.ModePerm); err != nil {
  753. return fmt.Errorf("create hooks dir '%s': %v", filepath.Join(hookDir, hookName+".d"), err)
  754. }
  755. // WARNING: This will override all old server-side hooks
  756. if err = ioutil.WriteFile(oldHookPath, []byte(hookTpl), 0777); err != nil {
  757. return fmt.Errorf("write old hook file '%s': %v", oldHookPath, err)
  758. }
  759. if err = ioutil.WriteFile(newHookPath, []byte(giteaHookTpls[i]), 0777); err != nil {
  760. return fmt.Errorf("write new hook file '%s': %v", newHookPath, err)
  761. }
  762. }
  763. return nil
  764. }
  765. // CleanUpMigrateInfo finishes migrating repository and/or wiki with things that don't need to be done for mirrors.
  766. func CleanUpMigrateInfo(repo *Repository) (*Repository, error) {
  767. repoPath := repo.RepoPath()
  768. if err := createDelegateHooks(repoPath); err != nil {
  769. return repo, fmt.Errorf("createDelegateHooks: %v", err)
  770. }
  771. if repo.HasWiki() {
  772. if err := createDelegateHooks(repo.WikiPath()); err != nil {
  773. return repo, fmt.Errorf("createDelegateHooks.(wiki): %v", err)
  774. }
  775. }
  776. if err := cleanUpMigrateGitConfig(repo.GitConfigPath()); err != nil {
  777. return repo, fmt.Errorf("cleanUpMigrateGitConfig: %v", err)
  778. }
  779. if repo.HasWiki() {
  780. if err := cleanUpMigrateGitConfig(path.Join(repo.WikiPath(), "config")); err != nil {
  781. return repo, fmt.Errorf("cleanUpMigrateGitConfig (wiki): %v", err)
  782. }
  783. }
  784. return repo, UpdateRepository(repo, false)
  785. }
  786. // initRepoCommit temporarily changes with work directory.
  787. func initRepoCommit(tmpPath string, sig *git.Signature) (err error) {
  788. var stderr string
  789. if _, stderr, err = process.GetManager().ExecDir(-1,
  790. tmpPath, fmt.Sprintf("initRepoCommit (git add): %s", tmpPath),
  791. "git", "add", "--all"); err != nil {
  792. return fmt.Errorf("git add: %s", stderr)
  793. }
  794. if _, stderr, err = process.GetManager().ExecDir(-1,
  795. tmpPath, fmt.Sprintf("initRepoCommit (git commit): %s", tmpPath),
  796. "git", "commit", fmt.Sprintf("--author='%s <%s>'", sig.Name, sig.Email),
  797. "-m", "Initial commit"); err != nil {
  798. return fmt.Errorf("git commit: %s", stderr)
  799. }
  800. if _, stderr, err = process.GetManager().ExecDir(-1,
  801. tmpPath, fmt.Sprintf("initRepoCommit (git push): %s", tmpPath),
  802. "git", "push", "origin", "master"); err != nil {
  803. return fmt.Errorf("git push: %s", stderr)
  804. }
  805. return nil
  806. }
  807. // CreateRepoOptions contains the create repository options
  808. type CreateRepoOptions struct {
  809. Name string
  810. Description string
  811. Gitignores string
  812. License string
  813. Readme string
  814. IsPrivate bool
  815. IsMirror bool
  816. AutoInit bool
  817. }
  818. func getRepoInitFile(tp, name string) ([]byte, error) {
  819. cleanedName := strings.TrimLeft(name, "./")
  820. relPath := path.Join("options", tp, cleanedName)
  821. // Use custom file when available.
  822. customPath := path.Join(setting.CustomPath, relPath)
  823. if com.IsFile(customPath) {
  824. return ioutil.ReadFile(customPath)
  825. }
  826. switch tp {
  827. case "readme":
  828. return options.Readme(cleanedName)
  829. case "gitignore":
  830. return options.Gitignore(cleanedName)
  831. case "license":
  832. return options.License(cleanedName)
  833. case "label":
  834. return options.Labels(cleanedName)
  835. default:
  836. return []byte{}, fmt.Errorf("Invalid init file type")
  837. }
  838. }
  839. func prepareRepoCommit(repo *Repository, tmpDir, repoPath string, opts CreateRepoOptions) error {
  840. // Clone to temporary path and do the init commit.
  841. _, stderr, err := process.GetManager().Exec(
  842. fmt.Sprintf("initRepository(git clone): %s", repoPath),
  843. "git", "clone", repoPath, tmpDir,
  844. )
  845. if err != nil {
  846. return fmt.Errorf("git clone: %v - %s", err, stderr)
  847. }
  848. // README
  849. data, err := getRepoInitFile("readme", opts.Readme)
  850. if err != nil {
  851. return fmt.Errorf("getRepoInitFile[%s]: %v", opts.Readme, err)
  852. }
  853. cloneLink := repo.CloneLink()
  854. match := map[string]string{
  855. "Name": repo.Name,
  856. "Description": repo.Description,
  857. "CloneURL.SSH": cloneLink.SSH,
  858. "CloneURL.HTTPS": cloneLink.HTTPS,
  859. }
  860. if err = ioutil.WriteFile(filepath.Join(tmpDir, "README.md"),
  861. []byte(com.Expand(string(data), match)), 0644); err != nil {
  862. return fmt.Errorf("write README.md: %v", err)
  863. }
  864. // .gitignore
  865. if len(opts.Gitignores) > 0 {
  866. var buf bytes.Buffer
  867. names := strings.Split(opts.Gitignores, ",")
  868. for _, name := range names {
  869. data, err = getRepoInitFile("gitignore", name)
  870. if err != nil {
  871. return fmt.Errorf("getRepoInitFile[%s]: %v", name, err)
  872. }
  873. buf.WriteString("# ---> " + name + "\n")
  874. buf.Write(data)
  875. buf.WriteString("\n")
  876. }
  877. if buf.Len() > 0 {
  878. if err = ioutil.WriteFile(filepath.Join(tmpDir, ".gitignore"), buf.Bytes(), 0644); err != nil {
  879. return fmt.Errorf("write .gitignore: %v", err)
  880. }
  881. }
  882. }
  883. // LICENSE
  884. if len(opts.License) > 0 {
  885. data, err = getRepoInitFile("license", opts.License)
  886. if err != nil {
  887. return fmt.Errorf("getRepoInitFile[%s]: %v", opts.License, err)
  888. }
  889. if err = ioutil.WriteFile(filepath.Join(tmpDir, "LICENSE"), data, 0644); err != nil {
  890. return fmt.Errorf("write LICENSE: %v", err)
  891. }
  892. }
  893. return nil
  894. }
  895. // InitRepository initializes README and .gitignore if needed.
  896. func initRepository(e Engine, repoPath string, u *User, repo *Repository, opts CreateRepoOptions) (err error) {
  897. // Somehow the directory could exist.
  898. if com.IsExist(repoPath) {
  899. return fmt.Errorf("initRepository: path already exists: %s", repoPath)
  900. }
  901. // Init bare new repository.
  902. if err = git.InitRepository(repoPath, true); err != nil {
  903. return fmt.Errorf("InitRepository: %v", err)
  904. } else if err = createDelegateHooks(repoPath); err != nil {
  905. return fmt.Errorf("createDelegateHooks: %v", err)
  906. }
  907. tmpDir := filepath.Join(os.TempDir(), "gitea-"+repo.Name+"-"+com.ToStr(time.Now().Nanosecond()))
  908. // Initialize repository according to user's choice.
  909. if opts.AutoInit {
  910. if err := os.MkdirAll(tmpDir, os.ModePerm); err != nil {
  911. return fmt.Errorf("Failed to create dir %s: %v", tmpDir, err)
  912. }
  913. defer os.RemoveAll(tmpDir)
  914. if err = prepareRepoCommit(repo, tmpDir, repoPath, opts); err != nil {
  915. return fmt.Errorf("prepareRepoCommit: %v", err)
  916. }
  917. // Apply changes and commit.
  918. if err = initRepoCommit(tmpDir, u.NewGitSig()); err != nil {
  919. return fmt.Errorf("initRepoCommit: %v", err)
  920. }
  921. }
  922. // Re-fetch the repository from database before updating it (else it would
  923. // override changes that were done earlier with sql)
  924. if repo, err = getRepositoryByID(e, repo.ID); err != nil {
  925. return fmt.Errorf("getRepositoryByID: %v", err)
  926. }
  927. if !opts.AutoInit {
  928. repo.IsBare = true
  929. }
  930. repo.DefaultBranch = "master"
  931. if err = updateRepository(e, repo, false); err != nil {
  932. return fmt.Errorf("updateRepository: %v", err)
  933. }
  934. return nil
  935. }
  936. var (
  937. reservedRepoNames = []string{".", ".."}
  938. reservedRepoPatterns = []string{"*.git", "*.wiki"}
  939. )
  940. // IsUsableRepoName returns true when repository is usable
  941. func IsUsableRepoName(name string) error {
  942. return isUsableName(reservedRepoNames, reservedRepoPatterns, name)
  943. }
  944. func createRepository(e *xorm.Session, u *User, repo *Repository) (err error) {
  945. if err = IsUsableRepoName(repo.Name); err != nil {
  946. return err
  947. }
  948. has, err := isRepositoryExist(e, u, repo.Name)
  949. if err != nil {
  950. return fmt.Errorf("IsRepositoryExist: %v", err)
  951. } else if has {
  952. return ErrRepoAlreadyExist{u.Name, repo.Name}
  953. }
  954. if _, err = e.Insert(repo); err != nil {
  955. return err
  956. }
  957. if err = deleteRepoRedirect(e, u.ID, repo.Name); err != nil {
  958. return err
  959. }
  960. // insert units for repo
  961. var units = make([]RepoUnit, 0, len(defaultRepoUnits))
  962. for i, tp := range defaultRepoUnits {
  963. units = append(units, RepoUnit{
  964. RepoID: repo.ID,
  965. Type: tp,
  966. Index: i,
  967. })
  968. }
  969. if _, err = e.Insert(&units); err != nil {
  970. return err
  971. }
  972. u.NumRepos++
  973. // Remember visibility preference.
  974. u.LastRepoVisibility = repo.IsPrivate
  975. if err = updateUser(e, u); err != nil {
  976. return fmt.Errorf("updateUser: %v", err)
  977. }
  978. // Give access to all members in owner team.
  979. if u.IsOrganization() {
  980. t, err := u.getOwnerTeam(e)
  981. if err != nil {
  982. return fmt.Errorf("getOwnerTeam: %v", err)
  983. } else if err = t.addRepository(e, repo); err != nil {
  984. return fmt.Errorf("addRepository: %v", err)
  985. }
  986. } else {
  987. // Organization automatically called this in addRepository method.
  988. if err = repo.recalculateAccesses(e); err != nil {
  989. return fmt.Errorf("recalculateAccesses: %v", err)
  990. }
  991. }
  992. if err = watchRepo(e, u.ID, repo.ID, true); err != nil {
  993. return fmt.Errorf("watchRepo: %v", err)
  994. } else if err = newRepoAction(e, u, repo); err != nil {
  995. return fmt.Errorf("newRepoAction: %v", err)
  996. }
  997. return nil
  998. }
  999. // CreateRepository creates a repository for given user or organization.
  1000. func CreateRepository(u *User, opts CreateRepoOptions) (_ *Repository, err error) {
  1001. if !u.CanCreateRepo() {
  1002. return nil, ErrReachLimitOfRepo{u.MaxRepoCreation}
  1003. }
  1004. repo := &Repository{
  1005. OwnerID: u.ID,
  1006. Owner: u,
  1007. Name: opts.Name,
  1008. LowerName: strings.ToLower(opts.Name),
  1009. Description: opts.Description,
  1010. IsPrivate: opts.IsPrivate,
  1011. }
  1012. sess := x.NewSession()
  1013. defer sessionRelease(sess)
  1014. if err = sess.Begin(); err != nil {
  1015. return nil, err
  1016. }
  1017. if err = createRepository(sess, u, repo); err != nil {
  1018. return nil, err
  1019. }
  1020. // No need for init mirror.
  1021. if !opts.IsMirror {
  1022. repoPath := RepoPath(u.Name, repo.Name)
  1023. if err = initRepository(sess, repoPath, u, repo, opts); err != nil {
  1024. if err2 := os.RemoveAll(repoPath); err2 != nil {
  1025. log.Error(4, "initRepository: %v", err)
  1026. return nil, fmt.Errorf(
  1027. "delete repo directory %s/%s failed(2): %v", u.Name, repo.Name, err2)
  1028. }
  1029. return nil, fmt.Errorf("initRepository: %v", err)
  1030. }
  1031. _, stderr, err := process.GetManager().ExecDir(-1,
  1032. repoPath, fmt.Sprintf("CreateRepository(git update-server-info): %s", repoPath),
  1033. "git", "update-server-info")
  1034. if err != nil {
  1035. return nil, errors.New("CreateRepository(git update-server-info): " + stderr)
  1036. }
  1037. }
  1038. return repo, sess.Commit()
  1039. }
  1040. func countRepositories(userID int64, private bool) int64 {
  1041. sess := x.Where("id > 0")
  1042. if userID > 0 {
  1043. sess.And("owner_id = ?", userID)
  1044. }
  1045. if !private {
  1046. sess.And("is_private=?", false)
  1047. }
  1048. count, err := sess.Count(new(Repository))
  1049. if err != nil {
  1050. log.Error(4, "countRepositories: %v", err)
  1051. }
  1052. return count
  1053. }
  1054. // CountRepositories returns number of repositories.
  1055. // Argument private only takes effect when it is false,
  1056. // set it true to count all repositories.
  1057. func CountRepositories(private bool) int64 {
  1058. return countRepositories(-1, private)
  1059. }
  1060. // CountUserRepositories returns number of repositories user owns.
  1061. // Argument private only takes effect when it is false,
  1062. // set it true to count all repositories.
  1063. func CountUserRepositories(userID int64, private bool) int64 {
  1064. return countRepositories(userID, private)
  1065. }
  1066. // RepoPath returns repository path by given user and repository name.
  1067. func RepoPath(userName, repoName string) string {
  1068. return filepath.Join(UserPath(userName), strings.ToLower(repoName)+".git")
  1069. }
  1070. // TransferOwnership transfers all corresponding setting from old user to new one.
  1071. func TransferOwnership(doer *User, newOwnerName string, repo *Repository) error {
  1072. newOwner, err := GetUserByName(newOwnerName)
  1073. if err != nil {
  1074. return fmt.Errorf("get new owner '%s': %v", newOwnerName, err)
  1075. }
  1076. // Check if new owner has repository with same name.
  1077. has, err := IsRepositoryExist(newOwner, repo.Name)
  1078. if err != nil {
  1079. return fmt.Errorf("IsRepositoryExist: %v", err)
  1080. } else if has {
  1081. return ErrRepoAlreadyExist{newOwnerName, repo.Name}
  1082. }
  1083. sess := x.NewSession()
  1084. defer sessionRelease(sess)
  1085. if err = sess.Begin(); err != nil {
  1086. return fmt.Errorf("sess.Begin: %v", err)
  1087. }
  1088. owner := repo.Owner
  1089. // Note: we have to set value here to make sure recalculate accesses is based on
  1090. // new owner.
  1091. repo.OwnerID = newOwner.ID
  1092. repo.Owner = newOwner
  1093. // Update repository.
  1094. if _, err := sess.Id(repo.ID).Update(repo); err != nil {
  1095. return fmt.Errorf("update owner: %v", err)
  1096. }
  1097. // Remove redundant collaborators.
  1098. collaborators, err := repo.getCollaborators(sess)
  1099. if err != nil {
  1100. return fmt.Errorf("getCollaborators: %v", err)
  1101. }
  1102. // Dummy object.
  1103. collaboration := &Collaboration{RepoID: repo.ID}
  1104. for _, c := range collaborators {
  1105. collaboration.UserID = c.ID
  1106. if c.ID == newOwner.ID || newOwner.IsOrgMember(c.ID) {
  1107. if _, err = sess.Delete(collaboration); err != nil {
  1108. return fmt.Errorf("remove collaborator '%d': %v", c.ID, err)
  1109. }
  1110. }
  1111. }
  1112. // Remove old team-repository relations.
  1113. if owner.IsOrganization() {
  1114. if err = owner.getTeams(sess); err != nil {
  1115. return fmt.Errorf("getTeams: %v", err)
  1116. }
  1117. for _, t := range owner.Teams {
  1118. if !t.hasRepository(sess, repo.ID) {
  1119. continue
  1120. }
  1121. t.NumRepos--
  1122. if _, err := sess.Id(t.ID).AllCols().Update(t); err != nil {
  1123. return fmt.Errorf("decrease team repository count '%d': %v", t.ID, err)
  1124. }
  1125. }
  1126. if err = owner.removeOrgRepo(sess, repo.ID); err != nil {
  1127. return fmt.Errorf("removeOrgRepo: %v", err)
  1128. }
  1129. }
  1130. if newOwner.IsOrganization() {
  1131. t, err := newOwner.getOwnerTeam(sess)
  1132. if err != nil {
  1133. return fmt.Errorf("getOwnerTeam: %v", err)
  1134. } else if err = t.addRepository(sess, repo); err != nil {
  1135. return fmt.Errorf("add to owner team: %v", err)
  1136. }
  1137. } else {
  1138. // Organization called this in addRepository method.
  1139. if err = repo.recalculateAccesses(sess); err != nil {
  1140. return fmt.Errorf("recalculateAccesses: %v", err)
  1141. }
  1142. }
  1143. // Update repository count.
  1144. if _, err = sess.Exec("UPDATE `user` SET num_repos=num_repos+1 WHERE id=?", newOwner.ID); err != nil {
  1145. return fmt.Errorf("increase new owner repository count: %v", err)
  1146. } else if _, err = sess.Exec("UPDATE `user` SET num_repos=num_repos-1 WHERE id=?", owner.ID); err != nil {
  1147. return fmt.Errorf("decrease old owner repository count: %v", err)
  1148. }
  1149. if err = watchRepo(sess, newOwner.ID, repo.ID, true); err != nil {
  1150. return fmt.Errorf("watchRepo: %v", err)
  1151. } else if err = transferRepoAction(sess, doer, owner, repo); err != nil {
  1152. return fmt.Errorf("transferRepoAction: %v", err)
  1153. }
  1154. // Rename remote repository to new path and delete local copy.
  1155. dir := UserPath(newOwner.Name)
  1156. if err := os.MkdirAll(dir, os.ModePerm); err != nil {
  1157. return fmt.Errorf("Failed to create dir %s: %v", dir, err)
  1158. }
  1159. if err = os.Rename(RepoPath(owner.Name, repo.Name), RepoPath(newOwner.Name, repo.Name)); err != nil {
  1160. return fmt.Errorf("rename repository directory: %v", err)
  1161. }
  1162. RemoveAllWithNotice("Delete repository local copy", repo.LocalCopyPath())
  1163. // Rename remote wiki repository to new path and delete local copy.
  1164. wikiPath := WikiPath(owner.Name, repo.Name)
  1165. if com.IsExist(wikiPath) {
  1166. RemoveAllWithNotice("Delete repository wiki local copy", repo.LocalWikiPath())
  1167. if err = os.Rename(wikiPath, WikiPath(newOwner.Name, repo.Name)); err != nil {
  1168. return fmt.Errorf("rename repository wiki: %v", err)
  1169. }
  1170. }
  1171. return sess.Commit()
  1172. }
  1173. // ChangeRepositoryName changes all corresponding setting from old repository name to new one.
  1174. func ChangeRepositoryName(u *User, oldRepoName, newRepoName string) (err error) {
  1175. oldRepoName = strings.ToLower(oldRepoName)
  1176. newRepoName = strings.ToLower(newRepoName)
  1177. if err = IsUsableRepoName(newRepoName); err != nil {
  1178. return err
  1179. }
  1180. has, err := IsRepositoryExist(u, newRepoName)
  1181. if err != nil {
  1182. return fmt.Errorf("IsRepositoryExist: %v", err)
  1183. } else if has {
  1184. return ErrRepoAlreadyExist{u.Name, newRepoName}
  1185. }
  1186. repo, err := GetRepositoryByName(u.ID, oldRepoName)
  1187. if err != nil {
  1188. return fmt.Errorf("GetRepositoryByName: %v", err)
  1189. }
  1190. // Change repository directory name.
  1191. if err = os.Rename(repo.RepoPath(), RepoPath(u.Name, newRepoName)); err != nil {
  1192. return fmt.Errorf("rename repository directory: %v", err)
  1193. }
  1194. wikiPath := repo.WikiPath()
  1195. if com.IsExist(wikiPath) {
  1196. if err = os.Rename(wikiPath, WikiPath(u.Name, newRepoName)); err != nil {
  1197. return fmt.Errorf("rename repository wiki: %v", err)
  1198. }
  1199. RemoveAllWithNotice("Delete repository wiki local copy", repo.LocalWikiPath())
  1200. }
  1201. return nil
  1202. }
  1203. func getRepositoriesByForkID(e Engine, forkID int64) ([]*Repository, error) {
  1204. repos := make([]*Repository, 0, 10)
  1205. return repos, e.
  1206. Where("fork_id=?", forkID).
  1207. Find(&repos)
  1208. }
  1209. // GetRepositoriesByForkID returns all repositories with given fork ID.
  1210. func GetRepositoriesByForkID(forkID int64) ([]*Repository, error) {
  1211. return getRepositoriesByForkID(x, forkID)
  1212. }
  1213. func updateRepository(e Engine, repo *Repository, visibilityChanged bool) (err error) {
  1214. repo.LowerName = strings.ToLower(repo.Name)
  1215. if len(repo.Description) > 255 {
  1216. repo.Description = repo.Description[:255]
  1217. }
  1218. if len(repo.Website) > 255 {
  1219. repo.Website = repo.Website[:255]
  1220. }
  1221. if _, err = e.Id(repo.ID).AllCols().Update(repo); err != nil {
  1222. return fmt.Errorf("update: %v", err)
  1223. }
  1224. if visibilityChanged {
  1225. if err = repo.getOwner(e); err != nil {
  1226. return fmt.Errorf("getOwner: %v", err)
  1227. }
  1228. if repo.Owner.IsOrganization() {
  1229. // Organization repository need to recalculate access table when visibility is changed.
  1230. if err = repo.recalculateTeamAccesses(e, 0); err != nil {
  1231. return fmt.Errorf("recalculateTeamAccesses: %v", err)
  1232. }
  1233. }
  1234. // If repo has become private, we need to set its actions to private.
  1235. if repo.IsPrivate {
  1236. _, err = e.Where("repo_id = ?", repo.ID).Cols("is_private").Update(&Action{
  1237. IsPrivate: true,
  1238. })
  1239. if err != nil {
  1240. return err
  1241. }
  1242. }
  1243. // Create/Remove git-daemon-export-ok for git-daemon...
  1244. daemonExportFile := path.Join(repo.RepoPath(), `git-daemon-export-ok`)
  1245. if repo.IsPrivate && com.IsExist(daemonExportFile) {
  1246. if err = os.Remove(daemonExportFile); err != nil {
  1247. log.Error(4, "Failed to remove %s: %v", daemonExportFile, err)
  1248. }
  1249. } else if !repo.IsPrivate && !com.IsExist(daemonExportFile) {
  1250. if f, err := os.Create(daemonExportFile); err != nil {
  1251. log.Error(4, "Failed to create %s: %v", daemonExportFile, err)
  1252. } else {
  1253. f.Close()
  1254. }
  1255. }
  1256. forkRepos, err := getRepositoriesByForkID(e, repo.ID)
  1257. if err != nil {
  1258. return fmt.Errorf("getRepositoriesByForkID: %v", err)
  1259. }
  1260. for i := range forkRepos {
  1261. forkRepos[i].IsPrivate = repo.IsPrivate
  1262. if err = updateRepository(e, forkRepos[i], true); err != nil {
  1263. return fmt.Errorf("updateRepository[%d]: %v", forkRepos[i].ID, err)
  1264. }
  1265. }
  1266. if err = repo.UpdateSize(); err != nil {
  1267. log.Error(4, "Failed to update size for repository: %v", err)
  1268. }
  1269. }
  1270. return nil
  1271. }
  1272. // UpdateRepository updates a repository
  1273. func UpdateRepository(repo *Repository, visibilityChanged bool) (err error) {
  1274. sess := x.NewSession()
  1275. defer sessionRelease(sess)
  1276. if err = sess.Begin(); err != nil {
  1277. return err
  1278. }
  1279. if err = updateRepository(sess, repo, visibilityChanged); err != nil {
  1280. return fmt.Errorf("updateRepository: %v", err)
  1281. }
  1282. return sess.Commit()
  1283. }
  1284. // UpdateRepositoryUnits updates a repository's units
  1285. func UpdateRepositoryUnits(repo *Repository, units []RepoUnit) (err error) {
  1286. sess := x.NewSession()
  1287. defer sess.Close()
  1288. if err = sess.Begin(); err != nil {
  1289. return err
  1290. }
  1291. if _, err = sess.Where("repo_id = ?", repo.ID).Delete(new(RepoUnit)); err != nil {
  1292. return err
  1293. }
  1294. if _, err = sess.Insert(units); err != nil {
  1295. return err
  1296. }
  1297. return sess.Commit()
  1298. }
  1299. // DeleteRepository deletes a repository for a user or organization.
  1300. func DeleteRepository(uid, repoID int64) error {
  1301. // In case is a organization.
  1302. org, err := GetUserByID(uid)
  1303. if err != nil {
  1304. return err
  1305. }
  1306. if org.IsOrganization() {
  1307. if err = org.GetTeams(); err != nil {
  1308. return err
  1309. }
  1310. }
  1311. sess := x.NewSession()
  1312. defer sessionRelease(sess)
  1313. if err = sess.Begin(); err != nil {
  1314. return err
  1315. }
  1316. repo := &Repository{ID: repoID, OwnerID: uid}
  1317. has, err := sess.Get(repo)
  1318. if err != nil {
  1319. return err
  1320. } else if !has {
  1321. return ErrRepoNotExist{repoID, uid, ""}
  1322. }
  1323. if cnt, err := sess.Id(repoID).Delete(&Repository{}); err != nil {
  1324. return err
  1325. } else if cnt != 1 {
  1326. return ErrRepoNotExist{repoID, uid, ""}
  1327. }
  1328. if org.IsOrganization() {
  1329. for _, t := range org.Teams {
  1330. if !t.hasRepository(sess, repoID) {
  1331. continue
  1332. } else if err = t.removeRepository(sess, repo, false); err != nil {
  1333. return err
  1334. }
  1335. }
  1336. }
  1337. if err = deleteBeans(sess,
  1338. &Access{RepoID: repo.ID},
  1339. &Action{RepoID: repo.ID},
  1340. &Watch{RepoID: repoID},
  1341. &Star{RepoID: repoID},
  1342. &Mirror{RepoID: repoID},
  1343. &Milestone{RepoID: repoID},
  1344. &Release{RepoID: repoID},
  1345. &Collaboration{RepoID: repoID},
  1346. &PullRequest{BaseRepoID: repoID},
  1347. ); err != nil {
  1348. return fmt.Errorf("deleteBeans: %v", err)
  1349. }
  1350. // Delete comments and attachments.
  1351. issueIDs := make([]int64, 0, 25)
  1352. attachmentPaths := make([]string, 0, len(issueIDs))
  1353. if err = sess.
  1354. Table("issue").
  1355. Cols("id").
  1356. Where("repo_id=?", repoID).
  1357. Find(&issueIDs); err != nil {
  1358. return err
  1359. }
  1360. if len(issueIDs) > 0 {
  1361. if _, err = sess.In("issue_id", issueIDs).Delete(&Comment{}); err != nil {
  1362. return err
  1363. }
  1364. if _, err = sess.In("issue_id", issueIDs).Delete(&IssueUser{}); err != nil {
  1365. return err
  1366. }
  1367. attachments := make([]*Attachment, 0, 5)
  1368. if err = sess.
  1369. In("issue_id", issueIDs).
  1370. Find(&attachments); err != nil {
  1371. return err
  1372. }
  1373. for j := range attachments {
  1374. attachmentPaths = append(attachmentPaths, attachments[j].LocalPath())
  1375. }
  1376. if _, err = sess.In("issue_id", issueIDs).Delete(&Attachment{}); err != nil {
  1377. return err
  1378. }
  1379. if _, err = sess.Delete(&Issue{RepoID: repoID}); err != nil {
  1380. return err
  1381. }
  1382. }
  1383. if _, err = sess.Where("repo_id = ?", repoID).Delete(new(RepoUnit)); err != nil {
  1384. return err
  1385. }
  1386. if repo.IsFork {
  1387. if _, err = sess.Exec("UPDATE `repository` SET num_forks=num_forks-1 WHERE id=?", repo.ForkID); err != nil {
  1388. return fmt.Errorf("decrease fork count: %v", err)
  1389. }
  1390. }
  1391. if _, err = sess.Exec("UPDATE `user` SET num_repos=num_repos-1 WHERE id=?", uid); err != nil {
  1392. return err
  1393. }
  1394. // FIXME: Remove repository files should be executed after transaction succeed.
  1395. repoPath := repo.repoPath(sess)
  1396. removeAllWithNotice(sess, "Delete repository files", repoPath)
  1397. repo.deleteWiki(sess)
  1398. // Remove attachment files.
  1399. for i := range attachmentPaths {
  1400. removeAllWithNotice(sess, "Delete attachment", attachmentPaths[i])
  1401. }
  1402. // Remove LFS objects
  1403. var lfsObjects []*LFSMetaObject
  1404. if err = sess.Where("repository_id=?", repoID).Find(&lfsObjects); err != nil {
  1405. return err
  1406. }
  1407. for _, v := range lfsObjects {
  1408. count, err := sess.Count(&LFSMetaObject{Oid: v.Oid})
  1409. if err != nil {
  1410. return err
  1411. }
  1412. if count > 1 {
  1413. continue
  1414. }
  1415. oidPath := filepath.Join(v.Oid[0:2], v.Oid[2:4], v.Oid[4:len(v.Oid)])
  1416. err = os.Remove(filepath.Join(setting.LFS.ContentPath, oidPath))
  1417. if err != nil {
  1418. return err
  1419. }
  1420. }
  1421. if _, err := sess.Delete(&LFSMetaObject{RepositoryID: repoID}); err != nil {
  1422. return err
  1423. }
  1424. if repo.NumForks > 0 {
  1425. if _, err = sess.Exec("UPDATE `repository` SET fork_id=0,is_fork=? WHERE fork_id=?", false, repo.ID); err != nil {
  1426. log.Error(4, "reset 'fork_id' and 'is_fork': %v", err)
  1427. }
  1428. }
  1429. if err = sess.Commit(); err != nil {
  1430. return fmt.Errorf("Commit: %v", err)
  1431. }
  1432. return nil
  1433. }
  1434. // GetRepositoryByRef returns a Repository specified by a GFM reference.
  1435. // See https://help.github.com/articles/writing-on-github#references for more information on the syntax.
  1436. func GetRepositoryByRef(ref string) (*Repository, error) {
  1437. n := strings.IndexByte(ref, byte('/'))
  1438. if n < 2 {
  1439. return nil, ErrInvalidReference
  1440. }
  1441. userName, repoName := ref[:n], ref[n+1:]
  1442. user, err := GetUserByName(userName)
  1443. if err != nil {
  1444. return nil, err
  1445. }
  1446. return GetRepositoryByName(user.ID, repoName)
  1447. }
  1448. // GetRepositoryByName returns the repository by given name under user if exists.
  1449. func GetRepositoryByName(ownerID int64, name string) (*Repository, error) {
  1450. repo := &Repository{
  1451. OwnerID: ownerID,
  1452. LowerName: strings.ToLower(name),
  1453. }
  1454. has, err := x.Get(repo)
  1455. if err != nil {
  1456. return nil, err
  1457. } else if !has {
  1458. return nil, ErrRepoNotExist{0, ownerID, name}
  1459. }
  1460. return repo, err
  1461. }
  1462. func getRepositoryByID(e Engine, id int64) (*Repository, error) {
  1463. repo := new(Repository)
  1464. has, err := e.Id(id).Get(repo)
  1465. if err != nil {
  1466. return nil, err
  1467. } else if !has {
  1468. return nil, ErrRepoNotExist{id, 0, ""}
  1469. }
  1470. return repo, nil
  1471. }
  1472. // GetRepositoryByID returns the repository by given id if exists.
  1473. func GetRepositoryByID(id int64) (*Repository, error) {
  1474. return getRepositoryByID(x, id)
  1475. }
  1476. // GetUserRepositories returns a list of repositories of given user.
  1477. func GetUserRepositories(userID int64, private bool, page, pageSize int, orderBy string) ([]*Repository, error) {
  1478. if len(orderBy) == 0 {
  1479. orderBy = "updated_unix DESC"
  1480. }
  1481. sess := x.
  1482. Where("owner_id = ?", userID).
  1483. OrderBy(orderBy)
  1484. if !private {
  1485. sess.And("is_private=?", false)
  1486. }
  1487. if page <= 0 {
  1488. page = 1
  1489. }
  1490. sess.Limit(pageSize, (page-1)*pageSize)
  1491. repos := make([]*Repository, 0, pageSize)
  1492. return repos, sess.Find(&repos)
  1493. }
  1494. // GetUserMirrorRepositories returns a list of mirror repositories of given user.
  1495. func GetUserMirrorRepositories(userID int64) ([]*Repository, error) {
  1496. repos := make([]*Repository, 0, 10)
  1497. return repos, x.
  1498. Where("owner_id = ?", userID).
  1499. And("is_mirror = ?", true).
  1500. Find(&repos)
  1501. }
  1502. func getRepositoryCount(e Engine, u *User) (int64, error) {
  1503. return e.Count(&Repository{OwnerID: u.ID})
  1504. }
  1505. func getPublicRepositoryCount(e Engine, u *User) (int64, error) {
  1506. return e.Where("is_private = ?", false).Count(&Repository{OwnerID: u.ID})
  1507. }
  1508. func getPrivateRepositoryCount(e Engine, u *User) (int64, error) {
  1509. return e.Where("is_private = ?", true).Count(&Repository{OwnerID: u.ID})
  1510. }
  1511. // GetRepositoryCount returns the total number of repositories of user.
  1512. func GetRepositoryCount(u *User) (int64, error) {
  1513. return getRepositoryCount(x, u)
  1514. }
  1515. // GetPublicRepositoryCount returns the total number of public repositories of user.
  1516. func GetPublicRepositoryCount(u *User) (int64, error) {
  1517. return getPublicRepositoryCount(x, u)
  1518. }
  1519. // GetPrivateRepositoryCount returns the total number of private repositories of user.
  1520. func GetPrivateRepositoryCount(u *User) (int64, error) {
  1521. return getPrivateRepositoryCount(x, u)
  1522. }
  1523. // DeleteRepositoryArchives deletes all repositories' archives.
  1524. func DeleteRepositoryArchives() error {
  1525. return x.
  1526. Where("id > 0").
  1527. Iterate(new(Repository),
  1528. func(idx int, bean interface{}) error {
  1529. repo := bean.(*Repository)
  1530. return os.RemoveAll(filepath.Join(repo.RepoPath(), "archives"))
  1531. })
  1532. }
  1533. // DeleteOldRepositoryArchives deletes old repository archives.
  1534. func DeleteOldRepositoryArchives() {
  1535. if taskStatusTable.IsRunning(archiveCleanup) {
  1536. return
  1537. }
  1538. taskStatusTable.Start(archiveCleanup)
  1539. defer taskStatusTable.Stop(archiveCleanup)
  1540. log.Trace("Doing: ArchiveCleanup")
  1541. if err := x.Where("id > 0").Iterate(new(Repository), deleteOldRepositoryArchives); err != nil {
  1542. log.Error(4, "ArchiveClean: %v", err)
  1543. }
  1544. }
  1545. func deleteOldRepositoryArchives(idx int, bean interface{}) error {
  1546. repo := bean.(*Repository)
  1547. basePath := filepath.Join(repo.RepoPath(), "archives")
  1548. for _, ty := range []string{"zip", "targz"} {
  1549. path := filepath.Join(basePath, ty)
  1550. file, err := os.Open(path)
  1551. if err != nil {
  1552. if !os.IsNotExist(err) {
  1553. log.Warn("Unable to open directory %s: %v", path, err)
  1554. return err
  1555. }
  1556. // If the directory doesn't exist, that's okay.
  1557. continue
  1558. }
  1559. files, err := file.Readdir(0)
  1560. file.Close()
  1561. if err != nil {
  1562. log.Warn("Unable to read directory %s: %v", path, err)
  1563. return err
  1564. }
  1565. minimumOldestTime := time.Now().Add(-setting.Cron.ArchiveCleanup.OlderThan)
  1566. for _, info := range files {
  1567. if info.ModTime().Before(minimumOldestTime) && !info.IsDir() {
  1568. toDelete := filepath.Join(path, info.Name())
  1569. // This is a best-effort purge, so we do not check error codes to confirm removal.
  1570. if err = os.Remove(toDelete); err != nil {
  1571. log.Trace("Unable to delete %s, but proceeding: %v", toDelete, err)
  1572. }
  1573. }
  1574. }
  1575. }
  1576. return nil
  1577. }
  1578. func gatherMissingRepoRecords() ([]*Repository, error) {
  1579. repos := make([]*Repository, 0, 10)
  1580. if err := x.
  1581. Where("id > 0").
  1582. Iterate(new(Repository),
  1583. func(idx int, bean interface{}) error {
  1584. repo := bean.(*Repository)
  1585. if !com.IsDir(repo.RepoPath()) {
  1586. repos = append(repos, repo)
  1587. }
  1588. return nil
  1589. }); err != nil {
  1590. if err2 := CreateRepositoryNotice(fmt.Sprintf("gatherMissingRepoRecords: %v", err)); err2 != nil {
  1591. return nil, fmt.Errorf("CreateRepositoryNotice: %v", err)
  1592. }
  1593. }
  1594. return repos, nil
  1595. }
  1596. // DeleteMissingRepositories deletes all repository records that lost Git files.
  1597. func DeleteMissingRepositories() error {
  1598. repos, err := gatherMissingRepoRecords()
  1599. if err != nil {
  1600. return fmt.Errorf("gatherMissingRepoRecords: %v", err)
  1601. }
  1602. if len(repos) == 0 {
  1603. return nil
  1604. }
  1605. for _, repo := range repos {
  1606. log.Trace("Deleting %d/%d...", repo.OwnerID, repo.ID)
  1607. if err := DeleteRepository(repo.OwnerID, repo.ID); err != nil {
  1608. if err2 := CreateRepositoryNotice(fmt.Sprintf("DeleteRepository [%d]: %v", repo.ID, err)); err2 != nil {
  1609. return fmt.Errorf("CreateRepositoryNotice: %v", err)
  1610. }
  1611. }
  1612. }
  1613. return nil
  1614. }
  1615. // ReinitMissingRepositories reinitializes all repository records that lost Git files.
  1616. func ReinitMissingRepositories() error {
  1617. repos, err := gatherMissingRepoRecords()
  1618. if err != nil {
  1619. return fmt.Errorf("gatherMissingRepoRecords: %v", err)
  1620. }
  1621. if len(repos) == 0 {
  1622. return nil
  1623. }
  1624. for _, repo := range repos {
  1625. log.Trace("Initializing %d/%d...", repo.OwnerID, repo.ID)
  1626. if err := git.InitRepository(repo.RepoPath(), true); err != nil {
  1627. if err2 := CreateRepositoryNotice(fmt.Sprintf("InitRepository [%d]: %v", repo.ID, err)); err2 != nil {
  1628. return fmt.Errorf("CreateRepositoryNotice: %v", err)
  1629. }
  1630. }
  1631. }
  1632. return nil
  1633. }
  1634. // SyncRepositoryHooks rewrites all repositories' pre-receive, update and post-receive hooks
  1635. // to make sure the binary and custom conf path are up-to-date.
  1636. func SyncRepositoryHooks() error {
  1637. return x.Where("id > 0").Iterate(new(Repository),
  1638. func(idx int, bean interface{}) error {
  1639. if err := createDelegateHooks(bean.(*Repository).RepoPath()); err != nil {
  1640. return fmt.Errorf("SyncRepositoryHook: %v", err)
  1641. }
  1642. if bean.(*Repository).HasWiki() {
  1643. if err := createDelegateHooks(bean.(*Repository).WikiPath()); err != nil {
  1644. return fmt.Errorf("SyncRepositoryHook: %v", err)
  1645. }
  1646. }
  1647. return nil
  1648. })
  1649. }
  1650. // Prevent duplicate running tasks.
  1651. var taskStatusTable = sync.NewStatusTable()
  1652. const (
  1653. mirrorUpdate = "mirror_update"
  1654. gitFsck = "git_fsck"
  1655. checkRepos = "check_repos"
  1656. archiveCleanup = "archive_cleanup"
  1657. )
  1658. // GitFsck calls 'git fsck' to check repository health.
  1659. func GitFsck() {
  1660. if taskStatusTable.IsRunning(gitFsck) {
  1661. return
  1662. }
  1663. taskStatusTable.Start(gitFsck)
  1664. defer taskStatusTable.Stop(gitFsck)
  1665. log.Trace("Doing: GitFsck")
  1666. if err := x.
  1667. Where("id>0").
  1668. Iterate(new(Repository),
  1669. func(idx int, bean interface{}) error {
  1670. repo := bean.(*Repository)
  1671. repoPath := repo.RepoPath()
  1672. if err := git.Fsck(repoPath, setting.Cron.RepoHealthCheck.Timeout, setting.Cron.RepoHealthCheck.Args...); err != nil {
  1673. desc := fmt.Sprintf("Failed to health check repository (%s): %v", repoPath, err)
  1674. log.Warn(desc)
  1675. if err = CreateRepositoryNotice(desc); err != nil {
  1676. log.Error(4, "CreateRepositoryNotice: %v", err)
  1677. }
  1678. }
  1679. return nil
  1680. }); err != nil {
  1681. log.Error(4, "GitFsck: %v", err)
  1682. }
  1683. }
  1684. // GitGcRepos calls 'git gc' to remove unnecessary files and optimize the local repository
  1685. func GitGcRepos() error {
  1686. args := append([]string{"gc"}, setting.Git.GCArgs...)
  1687. return x.
  1688. Where("id > 0").
  1689. Iterate(new(Repository),
  1690. func(idx int, bean interface{}) error {
  1691. repo := bean.(*Repository)
  1692. if err := repo.GetOwner(); err != nil {
  1693. return err
  1694. }
  1695. _, stderr, err := process.GetManager().ExecDir(
  1696. time.Duration(setting.Git.Timeout.GC)*time.Second,
  1697. RepoPath(repo.Owner.Name, repo.Name), "Repository garbage collection",
  1698. "git", args...)
  1699. if err != nil {
  1700. return fmt.Errorf("%v: %v", err, stderr)
  1701. }
  1702. return nil
  1703. })
  1704. }
  1705. type repoChecker struct {
  1706. querySQL, correctSQL string
  1707. desc string
  1708. }
  1709. func repoStatsCheck(checker *repoChecker) {
  1710. results, err := x.Query(checker.querySQL)
  1711. if err != nil {
  1712. log.Error(4, "Select %s: %v", checker.desc, err)
  1713. return
  1714. }
  1715. for _, result := range results {
  1716. id := com.StrTo(result["id"]).MustInt64()
  1717. log.Trace("Updating %s: %d", checker.desc, id)
  1718. _, err = x.Exec(checker.correctSQL, id, id)
  1719. if err != nil {
  1720. log.Error(4, "Update %s[%d]: %v", checker.desc, id, err)
  1721. }
  1722. }
  1723. }
  1724. // CheckRepoStats checks the repository stats
  1725. func CheckRepoStats() {
  1726. if taskStatusTable.IsRunning(checkRepos) {
  1727. return
  1728. }
  1729. taskStatusTable.Start(checkRepos)
  1730. defer taskStatusTable.Stop(checkRepos)
  1731. log.Trace("Doing: CheckRepoStats")
  1732. checkers := []*repoChecker{
  1733. // Repository.NumWatches
  1734. {
  1735. "SELECT repo.id FROM `repository` repo WHERE repo.num_watches!=(SELECT COUNT(*) FROM `watch` WHERE repo_id=repo.id)",
  1736. "UPDATE `repository` SET num_watches=(SELECT COUNT(*) FROM `watch` WHERE repo_id=?) WHERE id=?",
  1737. "repository count 'num_watches'",
  1738. },
  1739. // Repository.NumStars
  1740. {
  1741. "SELECT repo.id FROM `repository` repo WHERE repo.num_stars!=(SELECT COUNT(*) FROM `star` WHERE repo_id=repo.id)",
  1742. "UPDATE `repository` SET num_stars=(SELECT COUNT(*) FROM `star` WHERE repo_id=?) WHERE id=?",
  1743. "repository count 'num_stars'",
  1744. },
  1745. // Label.NumIssues
  1746. {
  1747. "SELECT label.id FROM `label` WHERE label.num_issues!=(SELECT COUNT(*) FROM `issue_label` WHERE label_id=label.id)",
  1748. "UPDATE `label` SET num_issues=(SELECT COUNT(*) FROM `issue_label` WHERE label_id=?) WHERE id=?",
  1749. "label count 'num_issues'",
  1750. },
  1751. // User.NumRepos
  1752. {
  1753. "SELECT `user`.id FROM `user` WHERE `user`.num_repos!=(SELECT COUNT(*) FROM `repository` WHERE owner_id=`user`.id)",
  1754. "UPDATE `user` SET num_repos=(SELECT COUNT(*) FROM `repository` WHERE owner_id=?) WHERE id=?",
  1755. "user count 'num_repos'",
  1756. },
  1757. // Issue.NumComments
  1758. {
  1759. "SELECT `issue`.id FROM `issue` WHERE `issue`.num_comments!=(SELECT COUNT(*) FROM `comment` WHERE issue_id=`issue`.id AND type=0)",
  1760. "UPDATE `issue` SET num_comments=(SELECT COUNT(*) FROM `comment` WHERE issue_id=? AND type=0) WHERE id=?",
  1761. "issue count 'num_comments'",
  1762. },
  1763. }
  1764. for i := range checkers {
  1765. repoStatsCheck(checkers[i])
  1766. }
  1767. // ***** START: Repository.NumClosedIssues *****
  1768. desc := "repository count 'num_closed_issues'"
  1769. results, err := x.Query("SELECT repo.id FROM `repository` repo WHERE repo.num_closed_issues!=(SELECT COUNT(*) FROM `issue` WHERE repo_id=repo.id AND is_closed=? AND is_pull=?)", true, false)
  1770. if err != nil {
  1771. log.Error(4, "Select %s: %v", desc, err)
  1772. } else {
  1773. for _, result := range results {
  1774. id := com.StrTo(result["id"]).MustInt64()
  1775. log.Trace("Updating %s: %d", desc, id)
  1776. _, err = x.Exec("UPDATE `repository` SET num_closed_issues=(SELECT COUNT(*) FROM `issue` WHERE repo_id=? AND is_closed=? AND is_pull=?) WHERE id=?", id, true, false, id)
  1777. if err != nil {
  1778. log.Error(4, "Update %s[%d]: %v", desc, id, err)
  1779. }
  1780. }
  1781. }
  1782. // ***** END: Repository.NumClosedIssues *****
  1783. // FIXME: use checker when stop supporting old fork repo format.
  1784. // ***** START: Repository.NumForks *****
  1785. results, err = x.Query("SELECT repo.id FROM `repository` repo WHERE repo.num_forks!=(SELECT COUNT(*) FROM `repository` WHERE fork_id=repo.id)")
  1786. if err != nil {
  1787. log.Error(4, "Select repository count 'num_forks': %v", err)
  1788. } else {
  1789. for _, result := range results {
  1790. id := com.StrTo(result["id"]).MustInt64()
  1791. log.Trace("Updating repository count 'num_forks': %d", id)
  1792. repo, err := GetRepositoryByID(id)
  1793. if err != nil {
  1794. log.Error(4, "GetRepositoryByID[%d]: %v", id, err)
  1795. continue
  1796. }
  1797. rawResult, err := x.Query("SELECT COUNT(*) FROM `repository` WHERE fork_id=?", repo.ID)
  1798. if err != nil {
  1799. log.Error(4, "Select count of forks[%d]: %v", repo.ID, err)
  1800. continue
  1801. }
  1802. repo.NumForks = int(parseCountResult(rawResult))
  1803. if err = UpdateRepository(repo, false); err != nil {
  1804. log.Error(4, "UpdateRepository[%d]: %v", id, err)
  1805. continue
  1806. }
  1807. }
  1808. }
  1809. // ***** END: Repository.NumForks *****
  1810. }
  1811. // ___________ __
  1812. // \_ _____/__________| | __
  1813. // | __)/ _ \_ __ \ |/ /
  1814. // | \( <_> ) | \/ <
  1815. // \___ / \____/|__| |__|_ \
  1816. // \/ \/
  1817. // HasForkedRepo checks if given user has already forked a repository with given ID.
  1818. func HasForkedRepo(ownerID, repoID int64) (*Repository, bool) {
  1819. repo := new(Repository)
  1820. has, _ := x.
  1821. Where("owner_id=? AND fork_id=?", ownerID, repoID).
  1822. Get(repo)
  1823. return repo, has
  1824. }
  1825. // ForkRepository forks a repository
  1826. func ForkRepository(u *User, oldRepo *Repository, name, desc string) (_ *Repository, err error) {
  1827. forkedRepo, err := oldRepo.GetUserFork(u.ID)
  1828. if err != nil {
  1829. return nil, err
  1830. }
  1831. if forkedRepo != nil {
  1832. return nil, ErrRepoAlreadyExist{
  1833. Uname: u.Name,
  1834. Name: forkedRepo.Name,
  1835. }
  1836. }
  1837. repo := &Repository{
  1838. OwnerID: u.ID,
  1839. Owner: u,
  1840. Name: name,
  1841. LowerName: strings.ToLower(name),
  1842. Description: desc,
  1843. DefaultBranch: oldRepo.DefaultBranch,
  1844. IsPrivate: oldRepo.IsPrivate,
  1845. IsFork: true,
  1846. ForkID: oldRepo.ID,
  1847. }
  1848. sess := x.NewSession()
  1849. defer sessionRelease(sess)
  1850. if err = sess.Begin(); err != nil {
  1851. return nil, err
  1852. }
  1853. if err = createRepository(sess, u, repo); err != nil {
  1854. return nil, err
  1855. }
  1856. if _, err = sess.Exec("UPDATE `repository` SET num_forks=num_forks+1 WHERE id=?", oldRepo.ID); err != nil {
  1857. return nil, err
  1858. }
  1859. repoPath := RepoPath(u.Name, repo.Name)
  1860. _, stderr, err := process.GetManager().ExecTimeout(10*time.Minute,
  1861. fmt.Sprintf("ForkRepository(git clone): %s/%s", u.Name, repo.Name),
  1862. "git", "clone", "--bare", oldRepo.RepoPath(), repoPath)
  1863. if err != nil {
  1864. return nil, fmt.Errorf("git clone: %v", stderr)
  1865. }
  1866. _, stderr, err = process.GetManager().ExecDir(-1,
  1867. repoPath, fmt.Sprintf("ForkRepository(git update-server-info): %s", repoPath),
  1868. "git", "update-server-info")
  1869. if err != nil {
  1870. return nil, fmt.Errorf("git update-server-info: %v", stderr)
  1871. }
  1872. if err = createDelegateHooks(repoPath); err != nil {
  1873. return nil, fmt.Errorf("createDelegateHooks: %v", err)
  1874. }
  1875. //Commit repo to get Fork ID
  1876. err = sess.Commit()
  1877. if err != nil {
  1878. return nil, err
  1879. }
  1880. if err = repo.UpdateSize(); err != nil {
  1881. log.Error(4, "Failed to update size for repository: %v", err)
  1882. }
  1883. // Copy LFS meta objects in new session
  1884. sess2 := x.NewSession()
  1885. defer sessionRelease(sess2)
  1886. if err = sess2.Begin(); err != nil {
  1887. return nil, err
  1888. }
  1889. var lfsObjects []*LFSMetaObject
  1890. if err = sess2.Where("repository_id=?", oldRepo.ID).Find(&lfsObjects); err != nil {
  1891. return nil, err
  1892. }
  1893. for _, v := range lfsObjects {
  1894. v.ID = 0
  1895. v.RepositoryID = repo.ID
  1896. if _, err = sess2.Insert(v); err != nil {
  1897. return nil, err
  1898. }
  1899. }
  1900. return repo, sess2.Commit()
  1901. }
  1902. // GetForks returns all the forks of the repository
  1903. func (repo *Repository) GetForks() ([]*Repository, error) {
  1904. forks := make([]*Repository, 0, repo.NumForks)
  1905. return forks, x.Find(&forks, &Repository{ForkID: repo.ID})
  1906. }
  1907. // GetUserFork return user forked repository from this repository, if not forked return nil
  1908. func (repo *Repository) GetUserFork(userID int64) (*Repository, error) {
  1909. var forkedRepo Repository
  1910. has, err := x.Where("fork_id = ?", repo.ID).And("owner_id = ?", userID).Get(&forkedRepo)
  1911. if err != nil {
  1912. return nil, err
  1913. }
  1914. if !has {
  1915. return nil, nil
  1916. }
  1917. return &forkedRepo, nil
  1918. }
  1919. // __________ .__
  1920. // \______ \____________ ____ ____ | |__
  1921. // | | _/\_ __ \__ \ / \_/ ___\| | \
  1922. // | | \ | | \// __ \| | \ \___| Y \
  1923. // |______ / |__| (____ /___| /\___ >___| /
  1924. // \/ \/ \/ \/ \/
  1925. //
  1926. // CreateNewBranch creates a new repository branch
  1927. func (repo *Repository) CreateNewBranch(doer *User, oldBranchName, branchName string) (err error) {
  1928. repoWorkingPool.CheckIn(com.ToStr(repo.ID))
  1929. defer repoWorkingPool.CheckOut(com.ToStr(repo.ID))
  1930. localPath := repo.LocalCopyPath()
  1931. if err = discardLocalRepoBranchChanges(localPath, oldBranchName); err != nil {
  1932. return fmt.Errorf("discardLocalRepoChanges: %v", err)
  1933. } else if err = repo.UpdateLocalCopyBranch(oldBranchName); err != nil {
  1934. return fmt.Errorf("UpdateLocalCopyBranch: %v", err)
  1935. }
  1936. if err = repo.CheckoutNewBranch(oldBranchName, branchName); err != nil {
  1937. return fmt.Errorf("CreateNewBranch: %v", err)
  1938. }
  1939. if err = git.Push(localPath, "origin", branchName); err != nil {
  1940. return fmt.Errorf("Push: %v", err)
  1941. }
  1942. return nil
  1943. }