Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
9b07ed06
Commit
9b07ed06
authored
Dec 20, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2323 from riyad/rename-tasks
Rename tasks
parents
2a3f5dae
1acff973
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
131 additions
and
108 deletions
+131
-108
doc/raketasks/backup_restore.md
doc/raketasks/backup_restore.md
+2
-2
doc/raketasks/features.md
doc/raketasks/features.md
+3
-3
doc/raketasks/maintenance.md
doc/raketasks/maintenance.md
+10
-0
doc/raketasks/user_management.md
doc/raketasks/user_management.md
+2
-2
lib/tasks/bulk_add_permission.rake
lib/tasks/bulk_add_permission.rake
+0
-20
lib/tasks/gitlab/backup.rake
lib/tasks/gitlab/backup.rake
+71
-67
lib/tasks/gitlab/bulk_add_permission.rake
lib/tasks/gitlab/bulk_add_permission.rake
+24
-0
lib/tasks/gitlab/check.rake
lib/tasks/gitlab/check.rake
+3
-1
lib/tasks/gitlab/enable_automerge.rake
lib/tasks/gitlab/enable_automerge.rake
+14
-11
lib/tasks/gitlab/enable_namespaces.rake
lib/tasks/gitlab/enable_namespaces.rake
+1
-1
lib/tasks/gitlab/setup.rake
lib/tasks/gitlab/setup.rake
+1
-1
No files found.
doc/raketasks/backup_restore.md
View file @
9b07ed06
...
@@ -4,7 +4,7 @@ Creates a backup archive of the database and all repositories. This archive will
...
@@ -4,7 +4,7 @@ Creates a backup archive of the database and all repositories. This archive will
The filename will be
`[TIMESTAMP]_gitlab_backup.tar`
. This timestamp can be used to restore an specific backup.
The filename will be
`[TIMESTAMP]_gitlab_backup.tar`
. This timestamp can be used to restore an specific backup.
```
```
bundle exec rake gitlab:
app:backup_
create
bundle exec rake gitlab:
backup:
create
```
```
Example output:
Example output:
...
@@ -40,7 +40,7 @@ Deleting old backups... [SKIPPING]
...
@@ -40,7 +40,7 @@ Deleting old backups... [SKIPPING]
### Restore a previously created backup
### Restore a previously created backup
```
```
bundle exec rake gitlab:
app:backup_
restore
bundle exec rake gitlab:
backup:
restore
```
```
Options:
Options:
...
...
doc/raketasks/features.md
View file @
9b07ed06
### Enable usernames and namespaces for user projects
### Enable usernames and namespaces for user projects
This command will enable the namespace feature introduced in v4.0. It will move every project in its namespace folder.
This command will enable the namespace
s
feature introduced in v4.0. It will move every project in its namespace folder.
Note:
Note:
...
@@ -13,7 +13,7 @@ Old path: `git@example.org:myrepo.git`
...
@@ -13,7 +13,7 @@ Old path: `git@example.org:myrepo.git`
New path:
`git@example.org:username/myrepo.git`
or
`git@example.org:groupname/myrepo.git`
New path:
`git@example.org:username/myrepo.git`
or
`git@example.org:groupname/myrepo.git`
```
```
bundle exec rake gitlab:
activat
e_namespaces
bundle exec rake gitlab:
enabl
e_namespaces
```
```
...
@@ -22,7 +22,7 @@ bundle exec rake gitlab:activate_namespaces
...
@@ -22,7 +22,7 @@ bundle exec rake gitlab:activate_namespaces
This command will enable the auto merge feature. After this you will be able to
**merge a merge request**
via GitLab and use the
**online editor**
.
This command will enable the auto merge feature. After this you will be able to
**merge a merge request**
via GitLab and use the
**online editor**
.
```
```
bundle exec rake gitlab:
app:
enable_automerge
bundle exec rake gitlab:enable_automerge
```
```
Example output:
Example output:
...
...
doc/raketasks/maintenance.md
View file @
9b07ed06
...
@@ -139,6 +139,16 @@ Checking GitLab ... Finished
...
@@ -139,6 +139,16 @@ Checking GitLab ... Finished
```
```
### (Re-)Create satellite repos
This will create satellite repos for all your projects.
If necessary, remove the
`tmp/repo_satellites`
directory and rerun the command below.
```
bundle exec rake gitlab:satellites:create
```
### Rebuild each key at gitolite config
### Rebuild each key at gitolite config
This will send all users ssh public keys to gitolite and grant them access (based on their permission) to their projects.
This will send all users ssh public keys to gitolite and grant them access (based on their permission) to their projects.
...
...
doc/raketasks/user_management.md
View file @
9b07ed06
### Add user to as a developer to all projects
### Add user to as a developer to all projects
```
```
bundle exec rake
add_user_to_project_team
s[username@domain.tld]
bundle exec rake
gitlab:import:user_to_project
s[username@domain.tld]
```
```
...
@@ -12,5 +12,5 @@ Notes:
...
@@ -12,5 +12,5 @@ Notes:
*
admin users are added as masters
*
admin users are added as masters
```
```
bundle exec rake
add_users_to_project_team
s
bundle exec rake
gitlab:import:all_users_to_all_project
s
```
```
lib/tasks/bulk_add_permission.rake
deleted
100644 → 0
View file @
2a3f5dae
desc
"Add all users to all projects (admin users are added as masters)"
task
:add_users_to_project_teams
=>
:environment
do
|
t
,
args
|
user_ids
=
User
.
where
(
:admin
=>
false
).
pluck
(
:id
)
admin_ids
=
User
.
where
(
:admin
=>
true
).
pluck
(
:id
)
Project
.
find_each
do
|
project
|
puts
"Importing
#{
user_ids
.
size
}
users into
#{
project
.
code
}
"
UsersProject
.
bulk_import
(
project
,
user_ids
,
UsersProject
::
DEVELOPER
)
puts
"Importing
#{
admin_ids
.
size
}
admins into
#{
project
.
code
}
"
UsersProject
.
bulk_import
(
project
,
admin_ids
,
UsersProject
::
MASTER
)
end
end
desc
"Add user to as a developer to all projects"
task
:add_user_to_project_teams
,
[
:email
]
=>
:environment
do
|
t
,
args
|
user
=
User
.
find_by_email
args
.
email
project_ids
=
Project
.
pluck
(
:id
)
UsersProject
.
user_bulk_import
(
user
,
project_ids
,
UsersProject
::
DEVELOPER
)
end
lib/tasks/gitlab/backup.rake
View file @
9b07ed06
require
'active_record/fixtures'
require
'active_record/fixtures'
namespace
:gitlab
do
namespace
:gitlab
do
namespace
:
ap
p
do
namespace
:
backu
p
do
# Create backup of GitLab system
# Create backup of GitLab system
desc
"GITLAB | Create a backup of the GitLab system"
desc
"GITLAB | Create a backup of the GitLab system"
task
:
backup_
create
=>
:environment
do
task
:create
=>
:environment
do
Rake
::
Task
[
"gitlab:
app:db_dump
"
].
invoke
Rake
::
Task
[
"gitlab:
backup:db:create
"
].
invoke
Rake
::
Task
[
"gitlab:
app:repo_dump
"
].
invoke
Rake
::
Task
[
"gitlab:
backup:repo:create
"
].
invoke
Dir
.
chdir
(
Gitlab
.
config
.
backup
.
path
)
Dir
.
chdir
(
Gitlab
.
config
.
backup
.
path
)
...
@@ -54,7 +54,7 @@ namespace :gitlab do
...
@@ -54,7 +54,7 @@ namespace :gitlab do
# Restore backup of GitLab system
# Restore backup of GitLab system
desc
"GITLAB | Restore a previously created backup"
desc
"GITLAB | Restore a previously created backup"
task
:
backup_
restore
=>
:environment
do
task
:restore
=>
:environment
do
Dir
.
chdir
(
Gitlab
.
config
.
backup
.
path
)
Dir
.
chdir
(
Gitlab
.
config
.
backup
.
path
)
# check for existing backups in the backup dir
# check for existing backups in the backup dir
...
@@ -62,7 +62,7 @@ namespace :gitlab do
...
@@ -62,7 +62,7 @@ namespace :gitlab do
puts
"no backups found"
if
file_list
.
count
==
0
puts
"no backups found"
if
file_list
.
count
==
0
if
file_list
.
count
>
1
&&
ENV
[
"BACKUP"
].
nil?
if
file_list
.
count
>
1
&&
ENV
[
"BACKUP"
].
nil?
puts
"Found more than one backup, please specify which one you want to restore:"
puts
"Found more than one backup, please specify which one you want to restore:"
puts
"rake gitlab:
app:backup_
restore BACKUP=timestamp_of_backup"
puts
"rake gitlab:
backup:
restore BACKUP=timestamp_of_backup"
exit
1
;
exit
1
;
end
end
...
@@ -93,8 +93,8 @@ namespace :gitlab do
...
@@ -93,8 +93,8 @@ namespace :gitlab do
exit
1
exit
1
end
end
Rake
::
Task
[
"gitlab:
app:db_
restore"
].
invoke
Rake
::
Task
[
"gitlab:
backup:db:
restore"
].
invoke
Rake
::
Task
[
"gitlab:
app:repo_
restore"
].
invoke
Rake
::
Task
[
"gitlab:
backup:repo:
restore"
].
invoke
# cleanup: remove tmp files
# cleanup: remove tmp files
print
"Deleting tmp directories..."
print
"Deleting tmp directories..."
...
@@ -110,7 +110,8 @@ namespace :gitlab do
...
@@ -110,7 +110,8 @@ namespace :gitlab do
################################# REPOSITORIES #################################
################################# REPOSITORIES #################################
task
:repo_dump
=>
:environment
do
namespace
:repo
do
task
:create
=>
:environment
do
backup_path_repo
=
File
.
join
(
Gitlab
.
config
.
backup
.
path
,
"repositories"
)
backup_path_repo
=
File
.
join
(
Gitlab
.
config
.
backup
.
path
,
"repositories"
)
FileUtils
.
mkdir_p
(
backup_path_repo
)
until
Dir
.
exists?
(
backup_path_repo
)
FileUtils
.
mkdir_p
(
backup_path_repo
)
until
Dir
.
exists?
(
backup_path_repo
)
puts
"Dumping repositories:"
puts
"Dumping repositories:"
...
@@ -126,7 +127,7 @@ namespace :gitlab do
...
@@ -126,7 +127,7 @@ namespace :gitlab do
end
end
end
end
task
:repo_
restore
=>
:environment
do
task
:
restore
=>
:environment
do
backup_path_repo
=
File
.
join
(
Gitlab
.
config
.
backup
.
path
,
"repositories"
)
backup_path_repo
=
File
.
join
(
Gitlab
.
config
.
backup
.
path
,
"repositories"
)
puts
"Restoring repositories:"
puts
"Restoring repositories:"
project
=
Project
.
all
.
map
{
|
n
|
[
n
.
path
,
n
.
path_to_repo
]
}
project
=
Project
.
all
.
map
{
|
n
|
[
n
.
path
,
n
.
path_to_repo
]
}
...
@@ -136,8 +137,8 @@ namespace :gitlab do
...
@@ -136,8 +137,8 @@ namespace :gitlab do
FileUtils
.
rm_rf
(
project
.
second
)
if
File
.
dirname
(
project
.
second
)
# delete old stuff
FileUtils
.
rm_rf
(
project
.
second
)
if
File
.
dirname
(
project
.
second
)
# delete old stuff
if
Kernel
.
system
(
"cd
#{
File
.
dirname
(
project
.
second
)
}
> /dev/null 2>&1 && git clone --bare
#{
backup_path_repo
}
/
#{
project
.
first
}
.bundle
#{
project
.
first
}
.git > /dev/null 2>&1"
)
if
Kernel
.
system
(
"cd
#{
File
.
dirname
(
project
.
second
)
}
> /dev/null 2>&1 && git clone --bare
#{
backup_path_repo
}
/
#{
project
.
first
}
.bundle
#{
project
.
first
}
.git > /dev/null 2>&1"
)
permission_commands
=
[
permission_commands
=
[
"sudo chmod -R g+rwX
#{
Gitlab
.
config
.
gitolite
.
repos
_path
}
"
,
"sudo chmod -R g+rwX
#{
Gitlab
.
config
.
git_base
_path
}
"
,
"sudo chown -R
#{
Gitlab
.
config
.
gitolite
.
ssh_user
}
:
#{
Gitlab
.
config
.
gitolite
.
ssh_user
}
#{
Gitlab
.
config
.
gitolite
.
repos
_path
}
"
"sudo chown -R
#{
Gitlab
.
config
.
ssh_user
}
:
#{
Gitlab
.
config
.
ssh_user
}
#{
Gitlab
.
config
.
git_base
_path
}
"
]
]
permission_commands
.
each
{
|
command
|
Kernel
.
system
(
command
)
}
permission_commands
.
each
{
|
command
|
Kernel
.
system
(
command
)
}
puts
"[DONE]"
.
green
puts
"[DONE]"
.
green
...
@@ -146,10 +147,12 @@ namespace :gitlab do
...
@@ -146,10 +147,12 @@ namespace :gitlab do
end
end
end
end
end
end
end
###################################### DB ######################################
###################################### DB ######################################
task
:db_dump
=>
:environment
do
namespace
:db
do
task
:create
=>
:environment
do
backup_path_db
=
File
.
join
(
Gitlab
.
config
.
backup
.
path
,
"db"
)
backup_path_db
=
File
.
join
(
Gitlab
.
config
.
backup
.
path
,
"db"
)
FileUtils
.
mkdir_p
(
backup_path_db
)
unless
Dir
.
exists?
(
backup_path_db
)
FileUtils
.
mkdir_p
(
backup_path_db
)
unless
Dir
.
exists?
(
backup_path_db
)
...
@@ -169,7 +172,7 @@ namespace :gitlab do
...
@@ -169,7 +172,7 @@ namespace :gitlab do
end
end
end
end
task
:db_
restore
=>
:environment
do
task
:
restore
=>
:environment
do
backup_path_db
=
File
.
join
(
Gitlab
.
config
.
backup
.
path
,
"db"
)
backup_path_db
=
File
.
join
(
Gitlab
.
config
.
backup
.
path
,
"db"
)
puts
"Restoring database tables:"
puts
"Restoring database tables:"
...
@@ -186,6 +189,7 @@ namespace :gitlab do
...
@@ -186,6 +189,7 @@ namespace :gitlab do
end
end
end
end
end
end
end
end
# namespace end:
ap
p
end
# namespace end:
backu
p
end
# namespace end: gitlab
end
# namespace end: gitlab
lib/tasks/gitlab/bulk_add_permission.rake
0 → 100644
View file @
9b07ed06
namespace
:gitlab
do
namespace
:import
do
desc
"GITLAB | Add all users to all projects (admin users are added as masters)"
task
:all_users_to_all_projects
=>
:environment
do
|
t
,
args
|
user_ids
=
User
.
where
(
:admin
=>
false
).
pluck
(
:id
)
admin_ids
=
User
.
where
(
:admin
=>
true
).
pluck
(
:id
)
Project
.
find_each
do
|
project
|
puts
"Importing
#{
user_ids
.
size
}
users into
#{
project
.
code
}
"
UsersProject
.
bulk_import
(
project
,
user_ids
,
UsersProject
::
DEVELOPER
)
puts
"Importing
#{
admin_ids
.
size
}
admins into
#{
project
.
code
}
"
UsersProject
.
bulk_import
(
project
,
admin_ids
,
UsersProject
::
MASTER
)
end
end
desc
"GITLAB | Add a specific user to all projects (as a developer)"
task
:user_to_projects
,
[
:email
]
=>
:environment
do
|
t
,
args
|
user
=
User
.
find_by_email
args
.
email
project_ids
=
Project
.
pluck
(
:id
)
UsersProject
.
user_bulk_import
(
user
,
project_ids
,
UsersProject
::
DEVELOPER
)
end
end
end
\ No newline at end of file
lib/tasks/gitlab/check.rake
View file @
9b07ed06
...
@@ -192,7 +192,9 @@ namespace :gitlab do
...
@@ -192,7 +192,9 @@ namespace :gitlab do
else
else
puts
"no"
.
red
puts
"no"
.
red
try_fixing_it
(
try_fixing_it
(
"sudo -u gitlab -H bundle exec rake gitlab:app:enable_automerge"
"sudo -u gitlab -H bundle exec rake gitlab:satellites:create"
,
"If necessary, remove the tmp/repo_satellites directory ..."
,
"... and rerun the above command"
)
)
for_more_information
(
for_more_information
(
"doc/raketasks/maintenance.md "
"doc/raketasks/maintenance.md "
...
...
lib/tasks/gitlab/enable_automerge.rake
View file @
9b07ed06
namespace
:gitlab
do
namespace
:gitlab
do
namespace
:app
do
desc
"GITLAB | Enable auto merge"
desc
"GITLAB | Enable auto merge"
task
:enable_automerge
=>
:environment
do
task
:enable_automerge
=>
:environment
do
Gitlab
::
Gitolite
.
new
.
enable_automerge
Gitlab
::
Gitolite
.
new
.
enable_automerge
...
@@ -13,5 +12,9 @@ namespace :gitlab do
...
@@ -13,5 +12,9 @@ namespace :gitlab do
puts
"Done!"
.
green
puts
"Done!"
.
green
end
end
namespace
:satellites
do
desc
"GITLAB | Create satellite repos"
task
create:
'gitlab:enable_automerge'
end
end
end
end
lib/tasks/gitlab/
activat
e_namespaces.rake
→
lib/tasks/gitlab/
enabl
e_namespaces.rake
View file @
9b07ed06
namespace
:gitlab
do
namespace
:gitlab
do
desc
"GITLAB | Enable usernames and namespaces for user projects"
desc
"GITLAB | Enable usernames and namespaces for user projects"
task
activat
e_namespaces: :environment
do
task
enabl
e_namespaces: :environment
do
print
"
\n
Usernames for users:"
.
yellow
print
"
\n
Usernames for users:"
.
yellow
User
.
find_each
(
batch_size:
500
)
do
|
user
|
User
.
find_each
(
batch_size:
500
)
do
|
user
|
...
...
lib/tasks/gitlab/setup.rake
View file @
9b07ed06
...
@@ -4,7 +4,7 @@ namespace :gitlab do
...
@@ -4,7 +4,7 @@ namespace :gitlab do
task
:setup
=>
[
task
:setup
=>
[
'db:setup'
,
'db:setup'
,
'db:seed_fu'
,
'db:seed_fu'
,
'gitlab:
app:
enable_automerge'
'gitlab:enable_automerge'
]
]
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment