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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
0e9d4f30
Commit
0e9d4f30
authored
Oct 26, 2012
by
Riyad Preukschas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor Satellite#clear and rename it to clear_and_update!
parent
fba8ad56
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
18 deletions
+43
-18
lib/gitlab/satellite/action.rb
lib/gitlab/satellite/action.rb
+1
-4
lib/gitlab/satellite/satellite.rb
lib/gitlab/satellite/satellite.rb
+42
-14
No files found.
lib/gitlab/satellite/action.rb
View file @
0e9d4f30
...
...
@@ -50,10 +50,7 @@ module Gitlab
#
# Note: use this within #in_locked_and_timed_satellite
def
prepare_satellite!
(
repo
)
project
.
satellite
.
clear
repo
.
git
.
reset
(
hard:
true
)
repo
.
git
.
fetch
({},
:origin
)
project
.
satellite
.
clear_and_update!
repo
.
git
.
config
({},
"user.name"
,
user
.
name
)
repo
.
git
.
config
({},
"user.email"
,
user
.
email
)
...
...
lib/gitlab/satellite/satellite.rb
View file @
0e9d4f30
...
...
@@ -9,20 +9,10 @@ module Gitlab
@project
=
project
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
def
clear_and_update!
delete_heads!
clear_working_dir!
update_from_source!
end
def
create
...
...
@@ -36,6 +26,44 @@ module Gitlab
def
path
Rails
.
root
.
join
(
"tmp"
,
"repo_satellites"
,
project
.
path
)
end
private
# Clear the working directory
def
clear_working_dir!
repo
.
git
.
reset
(
hard:
true
)
end
# Deletes all branches except the parking branch
#
# This ensures we have no name clashes or issues updating branches when
# working with the satellite.
def
delete_heads!
heads
=
repo
.
heads
.
map
{
|
head
|
head
.
name
}
# update or create the parking branch
if
heads
.
include?
PARKING_BRANCH
repo
.
git
.
checkout
({},
PARKING_BRANCH
)
else
repo
.
git
.
checkout
({
b:
true
},
PARKING_BRANCH
)
end
# remove the parking branch from the list of heads ...
heads
.
delete
(
PARKING_BRANCH
)
# ... and delete all others
heads
.
each
{
|
head
|
repo
.
git
.
branch
({
D
:
true
},
head
)
}
end
def
repo
@repo
||=
Grit
::
Repo
.
new
(
path
)
end
# Updates the satellite from Gitolite
#
# Note: this will only update remote branches (i.e. origin/*)
def
update_from_source!
repo
.
git
.
fetch
({},
:origin
)
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