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
Jérome Perrin
gitlab-ce
Commits
e5f8397f
Commit
e5f8397f
authored
Apr 22, 2012
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fast automerge: done
parent
dcbb875c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
21 deletions
+52
-21
app/models/project/hooks_trait.rb
app/models/project/hooks_trait.rb
+2
-2
app/models/project/repository_trait.rb
app/models/project/repository_trait.rb
+2
-15
lib/gitlab_merge.rb
lib/gitlab_merge.rb
+5
-2
lib/gitlabhq/satellite.rb
lib/gitlabhq/satellite.rb
+41
-0
lib/tasks/gitlab/enable_automerge.rake
lib/tasks/gitlab/enable_automerge.rake
+2
-2
No files found.
app/models/project/hooks_trait.rb
View file @
e5f8397f
...
...
@@ -102,8 +102,8 @@ module Project::HooksTrait
# Execute web hooks
self
.
execute_web_hooks
(
oldrev
,
newrev
,
ref
,
user
)
# Create
repo
satellite
self
.
create_repo_satellite
unless
self
.
satellite_
exists?
# Create satellite
self
.
satellite
.
create
unless
self
.
satellite
.
exists?
end
end
end
app/models/project/repository_trait.rb
View file @
e5f8397f
...
...
@@ -37,21 +37,8 @@ module Project::RepositoryTrait
end
end
def
path_to_repo_satellite
File
.
join
(
Rails
.
root
,
"tmp"
,
"repo_satellites"
,
self
.
path
)
end
def
satellite_exists?
File
.
exist?
path_to_repo_satellite
end
def
create_repo_satellite
`git clone
#{
url_to_repo
}
#{
path_to_repo_satellite
}
`
Dir
.
chdir
(
path_to_repo_satellite
)
do
primary_branch
=
Grit
::
Repo
.
new
(
"."
).
heads
.
first
.
name
#usually it`s master
`git checkout -b __parking_branch`
`git branch -D
#{
primary_branch
}
`
end
def
satellite
@satellite
||=
Gitlabhq
::
Satellite
.
new
(
self
)
end
def
write_hook
(
name
,
content
)
...
...
lib/gitlab_merge.rb
View file @
e5f8397f
...
...
@@ -29,10 +29,13 @@ class GitlabMerge
File
.
open
(
File
.
join
(
Rails
.
root
,
"tmp"
,
"merge_repo"
,
"
#{
project
.
path
}
.lock"
),
"w+"
)
do
|
f
|
f
.
flock
(
File
::
LOCK_EX
)
unless
project
.
satellite
_
exists?
unless
project
.
satellite
.
exists?
raise
"You should run: rake gitlab_enable_automerge"
end
Dir
.
chdir
(
project
.
path_to_repo_satellite
)
do
project
.
satellite
.
clear
Dir
.
chdir
(
project
.
satellite
.
path
)
do
merge_repo
=
Grit
::
Repo
.
new
(
'.'
)
merge_repo
.
git
.
sh
"git fetch origin"
merge_repo
.
git
.
sh
"git config user.name
\"
#{
user
.
name
}
\"
"
...
...
lib/gitlabhq/satellite.rb
0 → 100644
View file @
e5f8397f
module
Gitlabhq
class
Satellite
PARKING_BRANCH
=
"__parking_branch"
attr_accessor
:project
def
initialize
project
self
.
project
=
project
end
def
create
`git clone
#{
project
.
url_to_repo
}
#{
path
}
`
end
def
path
File
.
join
(
Rails
.
root
,
"tmp"
,
"repo_satellites"
,
project
.
path
)
end
def
exists?
File
.
exists?
path
end
#will be deleted all branches except PARKING_BRANCH
def
clear
Dir
.
chdir
(
path
)
do
heads
=
Grit
::
Repo
.
new
(
"."
).
heads
.
map
{
|
head
|
head
.
name
}
if
heads
.
include?
PARKING_BRANCH
`git checkout
#{
PARKING_BRANCH
}
`
else
`git checkout -b
#{
PARKING_BRANCH
}
`
end
heads
.
delete
(
PARKING_BRANCH
)
heads
.
each
do
|
head
|
`git branch -D
#{
head
}
`
end
end
end
end
end
lib/tasks/gitlab/enable_automerge.rake
View file @
e5f8397f
...
...
@@ -7,9 +7,9 @@ namespace :gitlab do
end
Project
.
find_each
do
|
project
|
if
project
.
repo_exists?
&&
!
project
.
satellite
_
exists?
if
project
.
repo_exists?
&&
!
project
.
satellite
.
exists?
puts
"Creating satellite for
#{
project
.
name
}
..."
.
green
project
.
create_repo_satelli
te
project
.
satellite
.
crea
te
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