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

repo.go 60KB

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