List of commits:
Subject Hash Author Date (UTC)
Fixed anon push without create branch rights 3d474b7a569b16d87a426d4c3b971a50b3299894 Catalin(ux) M. BOIE 2012-03-22 03:43:06
Use rg_repos for repositories e5bda9469fddee7f201c22dfd89292830f4c342b Catalin(ux) M. BOIE 2012-03-22 03:42:06
Corrected <label> tags 7e8621e79480b8964e04de8c54f10f1a702ea1fd Catalin(ux) M. BOIE 2012-03-20 04:25:38
Fixed unit testing 31bfe5672e7d3b620d0e7b3c07ff72d84c149001 Catalin(ux) M. BOIE 2012-03-17 17:21:21
Fixed hook_update.sh unit testing 86c4079e81efc5a4a7878e91d8f4318e443961f7 Catalin(ux) M. BOIE 2012-03-16 22:32:35
Bulk updates f696473a7faee50782d3cc01e96cc85e7900b3de Catalin(ux) M. BOIE 2012-03-14 04:38:23
Style changes. 87e30b1df29b7c6efa438be1cf369192a8068655 Catalin(ux) M. BOIE 2012-02-19 22:50:22
Bulk 0923407bff68a58a0b7b034f8a6b4489ece5b237 Catalin(ux) M. BOIE 2012-02-12 22:21:44
Bulk update 30310488bca37cefeba96b52b71c9c3e72c32907 Catalin(ux) M. BOIE 2011-12-15 23:34:03
Profiling tests. afd1df2940fe440cde9b8ede988ff24c051a10d6 Catalin(ux) M. BOIE 2011-11-03 22:10:13
More bulk updates. a2a2e2545eaad61d0c675ea2afb801f207534515 Catalin(ux) M. BOIE 2011-11-03 22:09:34
Another round of bulk updates. 45bb00a88c420d439b4dd19971808722e4a70895 Catalin(ux) M. BOIE 2011-10-24 22:31:14
Bulk update. Mostly css. 04734cd7cfc4fd4ec55dad70a3490f3065027639 Catalin(ux) M. BOIE 2011-10-03 23:18:26
Added rg_exec function and converted all calls from exec to rg_exec. 097157e5886dace2b9f67ca238a1063a3baff4a0 Catalin(ux) M. BOIE 2011-09-28 03:28:49
Another round of bulk updates cb9dbb75518ab3c214167646197ca7eb0de8e4e6 Catalin(ux) M. BOIE 2011-09-26 19:22:12
Bulk updates cad0c710542dc3fb072268eba40b0abe11217fa9 Catalin(ux) M. BOIE 2011-09-21 20:25:23
Bulk changes. d5274ef5f261086a2af6bd19ac04061bb3d55584 Catalin(ux) M. BOIE 2011-09-15 20:16:46
Store the fist instalation date in 'state' table. e4ba8a9239e72e8de5eed0b3bb1f2a5f2d429105 Catalin(ux) M. BOIE 2011-08-31 16:14:44
Bulk changes. 645d3deb19e399c05a8b14dd88c5151520482b6a Catalin(ux) M. BOIE 2011-08-25 20:39:25
Another bulk update - css related. 3867eb5deadf9827450b40a53efe6c83f518a07b Catalin(ux) M. BOIE 2011-07-26 22:01:13
Commit 3d474b7a569b16d87a426d4c3b971a50b3299894 - Fixed anon push without create branch rights
Author: Catalin(ux) M. BOIE
Author date (UTC): 2012-03-22 03:43
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2012-03-22 03:43
Parent(s): e5bda9469fddee7f201c22dfd89292830f4c342b
Signing key:
Tree: e303c4407164cf1e78ac3900be16c2f86b36d737
File Lines added Lines deleted
TODO 0 2
inc/git.inc.php 7 1
inc/rights.inc.php 1 1
inc/user/repo/edit/edit.php 1 1
scripts/remote.php 1 3
tests/hook_update_anon.sh 2 2
tests/hook_update_anon_nm.sh 20 14
File TODO changed (mode: 100644) (index e242427..02bb8c1)
3 3 [ ] Test and fix update.php script. [ ] Test and fix update.php script.
4 4 [ ] Check if rewinds are working as expected. [ ] Check if rewinds are working as expected.
5 5 [ ] Fix the "edit repo" page! [ ] Fix the "edit repo" page!
6 [ ] With FMH (Fetch + Anonymous push + merge commits) rights, seems that we insert a merge request,
7 but create branch is rejected in next hook!
8 6 [ ] 'cop' variable is not good - I do not remember what it means! [ ] 'cop' variable is not good - I do not remember what it means!
9 7 [ ] CSRF token is not used in admin page for an ordinary user! [ ] CSRF token is not used in admin page for an ordinary user!
10 8 [ ] Update db structure at any function call (after an upgrade). (Deny any operation till schema update is done.) [ ] Update db structure at any function call (after an upgrade). (Deny any operation till schema update is done.)
File inc/git.inc.php changed (mode: 100644) (index c6dff79..199c01e)
... ... function rg_git_update_branch($a)
826 826
827 827 rg_log("git_update_branch: " . rg_array2string($a)); rg_log("git_update_branch: " . rg_array2string($a));
828 828
829 // If we have anonymous push rights, we should add also create branch
830 if (rg_rights_allow($a['rights'], "H") === TRUE)
831 $a['rights'] .= "C";
832
829 833 if (strcmp($a['new_rev'], $rg_git_zero) == 0) { // delete if (strcmp($a['new_rev'], $rg_git_zero) == 0) { // delete
830 834 if (!rg_rights_allow($a['rights'], "D")) if (!rg_rights_allow($a['rights'], "D"))
831 835 rg_git_fatal($a['refname'] . "\nNo rights to delete" rg_git_fatal($a['refname'] . "\nNo rights to delete"
 
... ... function rg_git_update_branch($a)
880 884 } }
881 885
882 886 // anonymous push - create a merge request // anonymous push - create a merge request
883 // TODO: here, we may fail to update the reference;
887 // TODO: git may fail to update the reference after this hook;
884 888 // the mr code should check if the update was done. // the mr code should check if the update was done.
885 889 $r = rg_mr_queue_add($a['repo_id'], $a['namespace'], $r = rg_mr_queue_add($a['repo_id'], $a['namespace'],
886 890 $a['old_rev'], $a['new_rev'], $a['refname'], $a['ip']); $a['old_rev'], $a['new_rev'], $a['refname'], $a['ip']);
 
... ... function rg_git_update_branch($a)
891 895 } else { } else {
892 896 rg_log("We are allowed to push."); rg_log("We are allowed to push.");
893 897
898 // If we do not have a namespace, we let git to update the ref.
899 // Not clear when we do not have a namespace.
894 900 if (!empty($a['namespace'])) { if (!empty($a['namespace'])) {
895 901 // Update the main namespace // Update the main namespace
896 902 $r = rg_git_update_ref($a['refname'], $a['old_rev'], $r = rg_git_update_ref($a['refname'], $a['old_rev'],
File inc/rights.inc.php changed (mode: 100644) (index 4f7c6bf..3946e64)
... ... function rg_rights_checkboxes($type, $passed_rights)
92 92 if (strstr($passed_rights, $right)) if (strstr($passed_rights, $right))
93 93 $add = " checked=\"checked\""; $add = " checked=\"checked\"";
94 94 $ret .= "<input type=\"checkbox\" name=\"rights[$right]\"" $ret .= "<input type=\"checkbox\" name=\"rights[$right]\""
95 . $add . " />$info\n";
95 . $add . " />$info<br />\n";
96 96 } }
97 97
98 98 return $ret; return $ret;
File inc/user/repo/edit/edit.php changed (mode: 100644) (index fdde296..583d962)
... ... if ($doit == 1) {
23 23
24 24 while (1) { while (1) {
25 25 // lookup user // lookup user
26 $_ui = rg_user_info($db, 0, $user, "");
26 $_ui = rg_user_info($db, 0, $rr['user'], "");
27 27 if ($_ui['ok'] != 1) { if ($_ui['ok'] != 1) {
28 28 $errmsg[] = "Internal error!"; $errmsg[] = "Internal error!";
29 29 break; break;
File scripts/remote.php changed (mode: 100644) (index 1a3532a..4978f5f)
... ... if ($push == 1) {
179 179
180 180 // Prepare refs to not receive: // Prepare refs to not receive:
181 181 // "No refs in common and none specified; doing nothing. // "No refs in common and none specified; doing nothing.
182 // Perhaps you should specify a branch such as 'master'.
183 // No refs in common and none specified; doing nothing.
184 // Perhaps you should specify a branch such as 'master'.
182 // Perhaps you should specify a branch such as 'master'."
185 183 $dst = $repo_path . "/refs/namespaces/" . $namespace . "/refs/heads"; $dst = $repo_path . "/refs/namespaces/" . $namespace . "/refs/heads";
186 184 $ret = @mkdir($dst, 0755, TRUE); $ret = @mkdir($dst, 0755, TRUE);
187 185 if ($ret === FALSE) if ($ret === FALSE)
File tests/hook_update_anon.sh changed (mode: 100755) (index 8bd7a49..f2a299c)
... ... git add a
29 29 git commit -m "b" a git commit -m "b" a
30 30
31 31 echo "=== Testing anon push without rights..." echo "=== Testing anon push without rights..."
32 export ROCKETGIT_REPO_RIGHTS="C"
32 export ROCKETGIT_REPO_RIGHTS=""
33 33 git push origin master git push origin master
34 34 if [ "${?}" = "0" ]; then if [ "${?}" = "0" ]; then
35 35 echo "Should not work!" echo "Should not work!"
 
... ... fi
38 38
39 39 set -e set -e
40 40 echo "=== Testing anon push with rights..." echo "=== Testing anon push with rights..."
41 export ROCKETGIT_REPO_RIGHTS="CH"
41 export ROCKETGIT_REPO_RIGHTS="H"
42 42 git push origin master git push origin master
43 43 if [ "${?}" != "0" ]; then if [ "${?}" != "0" ]; then
44 44 echo "Should work!" echo "Should work!"
File tests/hook_update_anon_nm.sh copied from file tests/hook_update_anon.sh (similarity 61%) (mode: 100755) (index 8bd7a49..fd706f1)
1 1 #!/bin/bash #!/bin/bash
2 2
3 # Test anonymous push
3 # Test anonymous push with a custom branch
4 4
5 5 C=`pwd` C=`pwd`
6 P="hook_update_anon_nm"
6 7
7 rm -rf hook_update_anon_*.git
8 mkdir hook_update_anon_dest.git
8 rm -rf ${P}_*.git
9 mkdir ${P}_dest.git
9 10 ( (
10 cd hook_update_anon_dest.git
11 cd ${P}_dest.git
11 12 git init --bare git init --bare
12 13 ) )
13 cp ../hooks/* hook_update_anon_dest.git/hooks/
14 cp ../hooks/* ${P}_dest.git/hooks/
14 15
15 git clone hook_update_anon_dest.git hook_update_anon_src.git
16 git clone ${P}_dest.git ${P}_src.git
16 17
17 cd hook_update_anon_src.git
18 cd ${P}_src.git
18 19
19 export ROCKETGIT_REPO_ID=2000000000
20 export ROCKETGIT_REPO_ID=2000000001
20 21 export ROCKETGIT_IP="IP" export ROCKETGIT_IP="IP"
21 22 export GIT_NAMESPACE="abcdefgh" # we have to set it manually export GIT_NAMESPACE="abcdefgh" # we have to set it manually
22 23 export ROCKETGIT_MR_QUEUE="${C}/mr_queue" export ROCKETGIT_MR_QUEUE="${C}/mr_queue"
 
... ... echo "bbb" > a
28 29 git add a git add a
29 30 git commit -m "b" a git commit -m "b" a
30 31
32 echo "*** Creating a branch..."
33 export ROCKETGIT_REPO_RIGHTS="CP"
34 git checkout -b branch1
35 git push origin branch1
36
31 37 echo "=== Testing anon push without rights..." echo "=== Testing anon push without rights..."
32 export ROCKETGIT_REPO_RIGHTS="C"
38 export ROCKETGIT_REPO_RIGHTS=""
33 39 git push origin master git push origin master
34 40 if [ "${?}" = "0" ]; then if [ "${?}" = "0" ]; then
35 41 echo "Should not work!" echo "Should not work!"
 
... ... fi
38 44
39 45 set -e set -e
40 46 echo "=== Testing anon push with rights..." echo "=== Testing anon push with rights..."
41 export ROCKETGIT_REPO_RIGHTS="CH"
47 export ROCKETGIT_REPO_RIGHTS="H"
42 48 git push origin master git push origin master
43 49 if [ "${?}" != "0" ]; then if [ "${?}" != "0" ]; then
44 50 echo "Should work!" echo "Should work!"
45 51 exit 1 exit 1
46 52 fi fi
47 53 # Test if the namespace was updated instead of main namespace # Test if the namespace was updated instead of main namespace
48 diff ../hook_update_anon_dest.git/refs/namespaces/${GIT_NAMESPACE}/refs/heads/master \
54 diff ../${P}_dest.git/refs/namespaces/${GIT_NAMESPACE}/refs/heads/master \
49 55 .git/refs/heads/master .git/refs/heads/master
50 56 if [ "${?}" != "0" ]; then if [ "${?}" != "0" ]; then
51 57 echo "We did not update the namespace!" echo "We did not update the namespace!"
52 58 exit 1 exit 1
53 59 fi fi
54 if [ -r ../hook_update_anon_dest.git/refs/heads/master ]; then
60 if [ -r ../${P}_dest.git/refs/heads/master ]; then
55 61 echo "Seems we updated also main namespace!" echo "Seems we updated also main namespace!"
56 62 exit 1 exit 1
57 63 fi fi
 
... ... fi
64 70
65 71 cd .. cd ..
66 72
67 rm -rf hook_update_anon_*.git
73 rm -rf ${P}_*.git
68 74
69 echo "hook_update_anon: OK!"
75 echo "hook_update_anon_nm: OK!"
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/catalinux/rocketgit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/catalinux/rocketgit

Clone this repository using git:
git clone git://git.rocketgit.com/user/catalinux/rocketgit

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main