Check for chili.repositories.project_id. Indentations.

This commit is contained in:
Kolan Sh 2012-05-07 21:15:41 +04:00
parent 88fd369f21
commit aa6068773d
2 changed files with 44 additions and 25 deletions

View File

@ -11,7 +11,11 @@ else
fi fi
# === REMOVE ALL BROKEN REPOSITORY LINKS IN CHILIPROJECT MYSQL DATABASE === # === REMOVE ALL BROKEN REPOSITORY LINKS IN CHILIPROJECT MYSQL DATABASE ===
ALL_MYSQL_REPOS=`mysql -h$MYSQL_HOSTNAME -u $MYSQL_USER -e "SELECT url,root_url,id FROM $CHILI_MYSQL_DBNAME.repositories WHERE type='Git' OR type='Repository::Git'" | grep -v tables_col|xargs|sed "s/ /\n/g"|tail -n+4` ALL_MYSQL_REPOS=`mysql -h$MYSQL_HOSTNAME -u $MYSQL_USER -e "SELECT url,root_url,id
FROM $CHILI_MYSQL_DBNAME.repositories
WHERE type='Git'
OR type='Repository::Git'"
| grep -v tables_col|xargs|sed "s/ /\n/g"|tail -n+4`
repos_to_remove= repos_to_remove=
current_url= current_url=
current_root_url= current_root_url=
@ -31,8 +35,14 @@ repos_to_remove=${repos_to_remove#,}
# === GET DATA FROM GITORIOUS MYSQL BASE === # === GET DATA FROM GITORIOUS MYSQL BASE ===
CHILI_ID_GITORIOUS_REPO=`mysql -h$MYSQL_HOSTNAME -u $MYSQL_USER -e \ CHILI_ID_GITORIOUS_REPO=`mysql -h$MYSQL_HOSTNAME -u $MYSQL_USER -e \
"SELECT DISTINCT $CHILI_MYSQL_DBNAME.projects.id,$GITORIOUS_MYSQL_DBNAME.repositories.hashed_path "SELECT DISTINCT $CHILI_MYSQL_DBNAME.projects.id,$GITORIOUS_MYSQL_DBNAME.repositories.hashed_path
FROM $CHILI_MYSQL_DBNAME.member_roles,$CHILI_MYSQL_DBNAME.members,$CHILI_MYSQL_DBNAME.projects,$CHILI_MYSQL_DBNAME.roles, FROM $CHILI_MYSQL_DBNAME.member_roles,
$CHILI_MYSQL_DBNAME.users,$GITORIOUS_MYSQL_DBNAME.repositories,$GITORIOUS_MYSQL_DBNAME.roles,$GITORIOUS_MYSQL_DBNAME.users $CHILI_MYSQL_DBNAME.members,
$CHILI_MYSQL_DBNAME.projects,
$CHILI_MYSQL_DBNAME.roles,
$CHILI_MYSQL_DBNAME.users,
$GITORIOUS_MYSQL_DBNAME.repositories,
$GITORIOUS_MYSQL_DBNAME.roles,
$GITORIOUS_MYSQL_DBNAME.users
WHERE $CHILI_MYSQL_DBNAME.member_roles.member_id=$CHILI_MYSQL_DBNAME.members.id WHERE $CHILI_MYSQL_DBNAME.member_roles.member_id=$CHILI_MYSQL_DBNAME.members.id
AND $CHILI_MYSQL_DBNAME.member_roles.role_id=$CHILI_MYSQL_DBNAME.roles.id AND $CHILI_MYSQL_DBNAME.member_roles.role_id=$CHILI_MYSQL_DBNAME.roles.id
AND $CHILI_MYSQL_DBNAME.members.user_id=$CHILI_MYSQL_DBNAME.users.id AND $CHILI_MYSQL_DBNAME.members.user_id=$CHILI_MYSQL_DBNAME.users.id
@ -42,8 +52,8 @@ CHILI_ID_GITORIOUS_REPO=`mysql -h$MYSQL_HOSTNAME -u $MYSQL_USER -e \
AND $CHILI_MYSQL_DBNAME.users.type='User' AND $CHILI_MYSQL_DBNAME.users.type='User'
AND $CHILI_MYSQL_DBNAME.users.mail=$GITORIOUS_MYSQL_DBNAME.users.email AND $CHILI_MYSQL_DBNAME.users.mail=$GITORIOUS_MYSQL_DBNAME.users.email
AND $CHILI_MYSQL_DBNAME.roles.name IN ('Инициатор','Менеджер','Major','Manager') AND $CHILI_MYSQL_DBNAME.roles.name IN ('Инициатор','Менеджер','Major','Manager')
AND $GITORIOUS_MYSQL_DBNAME.repositories.user_id=$GITORIOUS_MYSQL_DBNAME.users.id; AND $GITORIOUS_MYSQL_DBNAME.repositories.user_id=$GITORIOUS_MYSQL_DBNAME.users.id;"
" | grep -v tables_col|xargs|sed "s/ /\n/g"|tail -n+3` | grep -v tables_col|xargs|sed "s/ /\n/g"|tail -n+3`
# add repositories paths to $CHILI_MYSQL_DBNAME.repositories # add repositories paths to $CHILI_MYSQL_DBNAME.repositories
chili_project_id= chili_project_id=
@ -58,8 +68,8 @@ for v in $CHILI_ID_GITORIOUS_REPO; do
ALREADY_EXIST=`mysql -h$MYSQL_HOSTNAME -u $MYSQL_USER -e "SELECT id ALREADY_EXIST=`mysql -h$MYSQL_HOSTNAME -u $MYSQL_USER -e "SELECT id
FROM $CHILI_MYSQL_DBNAME.repositories FROM $CHILI_MYSQL_DBNAME.repositories
WHERE project_id=$chili_project_id WHERE project_id=$chili_project_id
OR url='$gitorious_path' OR url='$gitorious_path'
OR root_url='$gitorious_path'" \ OR root_url='$gitorious_path'" \
| grep -v tables_col|xargs|sed "s/ /\n/g"|tail -n+2` | grep -v tables_col|xargs|sed "s/ /\n/g"|tail -n+2`
if [ "" == "$ALREADY_EXIST" ]; then if [ "" == "$ALREADY_EXIST" ]; then
# insert to $CHILI_MYSQL_DBNAME.repositories # insert to $CHILI_MYSQL_DBNAME.repositories

View File

@ -11,7 +11,11 @@ else
fi fi
# === REMOVE ALL BROKEN REPOSITORY LINKS IN CHILIPROJECT MYSQL DATABASE === # === REMOVE ALL BROKEN REPOSITORY LINKS IN CHILIPROJECT MYSQL DATABASE ===
ALL_MYSQL_REPOS=`mysql -h$CHILI_MYSQL_HOSTNAME -u $CHILI_MYSQL_USER -e "SELECT url,root_url,id FROM $CHILI_MYSQL_DBNAME.repositories WHERE type='Mercurial' OR type='Repository::Mercurial'" | grep -v tables_col|xargs|sed "s/ /\n/g"|tail -n+4` ALL_MYSQL_REPOS=`mysql -h$CHILI_MYSQL_HOSTNAME -u $CHILI_MYSQL_USER -e "SELECT url,root_url,id
FROM $CHILI_MYSQL_DBNAME.repositories
WHERE type='Mercurial'
OR type='Repository::Mercurial'"
| grep -v tables_col|xargs|sed "s/ /\n/g"|tail -n+4`
repos_to_remove= repos_to_remove=
current_url= current_url=
current_root_url= current_root_url=
@ -26,10 +30,14 @@ for v in $ALL_MYSQL_REPOS; do
let n++ let n++
done; done;
repos_to_remove=${repos_to_remove#,} repos_to_remove=${repos_to_remove#,}
[ "$repos_to_remove" != "" ] && mysql -h$CHILI_MYSQL_HOSTNAME -u $CHILI_MYSQL_USER -e "DELETE FROM $CHILI_MYSQL_DBNAME.repositories WHERE id IN ($repos_to_remove)" [ "$repos_to_remove" != "" ] && mysql -h$CHILI_MYSQL_HOSTNAME -u $CHILI_MYSQL_USER -e "DELETE
FROM $CHILI_MYSQL_DBNAME.repositories
WHERE id IN ($repos_to_remove)"
# === GET DATA FROM RHODECODE SQLITE BASE === # === GET DATA FROM RHODECODE SQLITE BASE ===
rh_repos_path=`sqlite3 $RHODECODE_SQLITE_PATH "select ui_value FROM rhodecode_ui where ui_section='paths'"` rh_repos_path=`sqlite3 $RHODECODE_SQLITE_PATH "SELECT ui_value
FROM rhodecode_ui
WHERE ui_section='paths'"`
SQLITE_RESULTS=`sqlite3 $RHODECODE_SQLITE_PATH "SELECT repo_name,repo_type,users.email SQLITE_RESULTS=`sqlite3 $RHODECODE_SQLITE_PATH "SELECT repo_name,repo_type,users.email
FROM repositories,users FROM repositories,users
@ -57,13 +65,6 @@ done
# === FOR ALL REPOS FROM RHODECODE DATABASE=== # === FOR ALL REPOS FROM RHODECODE DATABASE===
for i in `seq 0 $((nrepos-1))`; do for i in `seq 0 $((nrepos-1))`; do
# === GET DATA FROM CHILIPROJECT MYSQL BASE === # === GET DATA FROM CHILIPROJECT MYSQL BASE ===
ALREADY_EXIST=`mysql -h$CHILI_MYSQL_HOSTNAME -u $CHILI_MYSQL_USER -e "SELECT id
FROM $CHILI_MYSQL_DBNAME.repositories
WHERE url='${repos_paths[$i]}'
OR root_url='${repos_paths[$i]}'" \
| grep -v tables_col|xargs|sed "s/ /\n/g"|tail -n+2`
[ "$ALREADY_EXIST" != "" ] && continue
USERID=`mysql -h$CHILI_MYSQL_HOSTNAME -u $CHILI_MYSQL_USER -e "SELECT id USERID=`mysql -h$CHILI_MYSQL_HOSTNAME -u $CHILI_MYSQL_USER -e "SELECT id
FROM $CHILI_MYSQL_DBNAME.users FROM $CHILI_MYSQL_DBNAME.users
WHERE users.status='1' WHERE users.status='1'
@ -74,21 +75,29 @@ for i in `seq 0 $((nrepos-1))`; do
PROJECTID=`mysql -h$CHILI_MYSQL_HOSTNAME -u $CHILI_MYSQL_USER -e "SELECT id FROM $CHILI_MYSQL_DBNAME.projects PROJECTID=`mysql -h$CHILI_MYSQL_HOSTNAME -u $CHILI_MYSQL_USER -e "SELECT id FROM $CHILI_MYSQL_DBNAME.projects
WHERE (name='${repos_names[$i]}' WHERE (name='${repos_names[$i]}'
OR identifier='${repos_names[$i]}') OR identifier='${repos_names[$i]}')
AND status='1'" \ AND status='1'" \
| grep -v tables_col|xargs|sed "s/ /\n/g"|tail -n+2` | grep -v tables_col|xargs|sed "s/ /\n/g"|tail -n+2`
[ "$PROJECTID" == "" ] && continue [ "$PROJECTID" == "" ] && continue
ALREADY_EXIST=`mysql -h$CHILI_MYSQL_HOSTNAME -u $CHILI_MYSQL_USER -e "SELECT id
FROM $CHILI_MYSQL_DBNAME.repositories
WHERE project_id=$PROJECTID
OR url='${repos_paths[$i]}'
OR root_url='${repos_paths[$i]}'" \
| grep -v tables_col|xargs|sed "s/ /\n/g"|tail -n+2`
[ "$ALREADY_EXIST" != "" ] && continue
roles_mysql_string=`echo $CHILI_REQUIRED_ROLES | sed "s~\>~'~g ; s~\<~OR roles.name='~g ; s~^OR ~~"` roles_mysql_string=`echo $CHILI_REQUIRED_ROLES | sed "s~\>~'~g ; s~\<~OR roles.name='~g ; s~^OR ~~"`
ROLES=`mysql --default-character-set=utf8 -h$CHILI_MYSQL_HOSTNAME -u $CHILI_MYSQL_USER -e "SELECT roles.name ROLES=`mysql --default-character-set=utf8 -h$CHILI_MYSQL_HOSTNAME -u $CHILI_MYSQL_USER -e "SELECT roles.name
FROM $CHILI_MYSQL_DBNAME.roles, FROM $CHILI_MYSQL_DBNAME.roles,
$CHILI_MYSQL_DBNAME.member_roles, $CHILI_MYSQL_DBNAME.member_roles,
$CHILI_MYSQL_DBNAME.members $CHILI_MYSQL_DBNAME.members
WHERE roles.id=member_roles.role_id WHERE roles.id=member_roles.role_id
AND member_roles.member_id=members.id AND member_roles.member_id=members.id
AND members.user_id='$USERID' AND members.user_id='$USERID'
AND members.project_id='$PROJECTID' AND members.project_id='$PROJECTID'
AND ($roles_mysql_string)" \ AND ($roles_mysql_string)" \
| grep -v tables_col|xargs|sed "s/ /\n/g"|tail -n+2` | grep -v tables_col|xargs|sed "s/ /\n/g"|tail -n+2`
[ "$ROLES" == "" ] && continue [ "$ROLES" == "" ] && continue