Difference between revisions of "Service/git"

From Sugar Labs
Jump to: navigation, search
(Upgrade notes)
(Notes)
Line 32: Line 32:
 
|}
 
|}
  
=== Gitorious environments ===
+
=== Database tweaks ===
  
We do not have root on git.sugarlabs.org. Put the following aliases in your
+
To make runtime changes in Gitorious database, follow regular Rails workflow - run {{Code|scripts/console}}:
~/.bashrc to quickly switch to the Gitorious production, test and development
 
environments:
 
  
  alias gitorious='sudo su - gitorious'
+
  cd /srv/gitorious/app
  alias gittest='sudo su - gittest'
+
  sudo -u gitorious RAILS_ENV=production script/console
alias gitdev='sudo su - gitdev'
 
alias db='mysql -h db1.osuosl.org -u sugarlabs_git -p  sugarlabs_git_dev'
 
  
=== Get a MySQL prompt ===
+
It is regular Ruby console and all feature like {{Code|TAB}} completion work. To tweak Gitorious data, just use its [http://gitorious.org/gitorious/mainline/trees/master/app/models model classes], e.g.:
type "db" at the prompt, then give the db password
 
from ~gitorious/config/database.yml
 
  
=== Change project owner ===
+
# search of particular object by its attributes
  UPDATE projects SET user_id=(SELECT id FROM users WHERE login='jasg') WHERE slug='labyrinth';
+
user = User.find_by_login("user")
 +
project = User.find_by_title("project")
 +
 +
# change object attributes
 +
  project.owner = User.find_by_email("foo@bas")
 +
project.save!
 +
 +
# destroy object and all its dependencies
 +
user.destroy
  
=== Change repo owner ===
+
=== Tips ===
UPDATE repositories SET user_id=(SELECT id FROM users WHERE login='jasg') WHERE name='mainline' AND project_id=(SELECT id FROM projects WHERE title='poll');
 
  
=== Add committer ===
+
  # reset user password
  INSERT INTO committerships SET
+
  user = User.find_by_login("user")
        user_id=(select id from users where login='bernie'),
+
  password_key = user.forgot_password!
        repository_id=(SELECT id FROM repositories where
+
  Mailer.deliver_forgotten_password(user, password_key)
                project_id=(SELECT id FROM projects WHERE title='sugar') AND name='mainline'),
 
        kind=2, created_at=NOW(), updated_at=NOW();
 
 
 
=== Hijack account to reset password ===
 
  update users set email='YOUREMAIL' where login='USER';
 
 
 
Then make Gitorious send you a password reset email.
 
 
 
  update users set email='OLDEMAIL' where login='USER';
 
 
 
=== Zapping a user account ===
 
 
 
WARNING: to kill a user account, make sure you also remove *ALL* its associated records
 
from all tables, or Gitorious will break in non-obvious ways.
 
 
 
SELECT id FROM users WHERE login='demian';
 
DELETE FROM committers WHERE user_id=666;
 
DELETE FROM events WHERE user_id=666;
 
DELETE FROM comments WHERE user_id=666;
 
DELETE FROM merge_requests WHERE user_id=666;
 
  DELETE FROM repositories WHERE user_id=666;
 
DELETE FROM projects WHERE user_id=666;
 
 
 
NOTE: tch pointed out that Rails applications often provide a higher-level method
 
in class User which deletes the record and its associated entries. However, our
 
deployed version of Gitorious does not seem to provide it.
 
 
 
=== Restart gitorious after code/config changes ===
 
touch tmp/restart.txt
 
  
 
== Upgrade notes ==
 
== Upgrade notes ==
  
 
Upgrade will be triggered on every puppet session (if there is such need), vcs repository will be rebased to the HEAD commit with all related changes like database migration.
 
Upgrade will be triggered on every puppet session (if there is such need), vcs repository will be rebased to the HEAD commit with all related changes like database migration.

Revision as of 13:56, 10 November 2010

Hostnames

Hardware

Machine/jita

Administrative contact

git AT sugarlabs DOT org

Sysadmins

For non-emergency calls, preferably send email to the administrative contact.

  • Aleksey Lim
  • puppet related stuff is still in progress of settling down

Notes

Gitorious hosting.

Home /srv/gitorious
Main service gitorious-all

Database tweaks

To make runtime changes in Gitorious database, follow regular Rails workflow - run scripts/console:

cd /srv/gitorious/app
sudo -u gitorious RAILS_ENV=production script/console

It is regular Ruby console and all feature like TAB completion work. To tweak Gitorious data, just use its model classes, e.g.:

# search of particular object by its attributes
user = User.find_by_login("user")
project = User.find_by_title("project")

# change object attributes
project.owner = User.find_by_email("foo@bas")
project.save!

# destroy object and all its dependencies
user.destroy

Tips

# reset user password
user = User.find_by_login("user")
password_key = user.forgot_password!
Mailer.deliver_forgotten_password(user, password_key)

Upgrade notes

Upgrade will be triggered on every puppet session (if there is such need), vcs repository will be rebased to the HEAD commit with all related changes like database migration.