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