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
Kazuhiko Shiozaki
gitlab-ce
Commits
b26abe8f
Commit
b26abe8f
authored
Nov 19, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delete file action for satellites
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
60959df3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
0 deletions
+43
-0
lib/gitlab/satellite/files/delete_file_action.rb
lib/gitlab/satellite/files/delete_file_action.rb
+43
-0
No files found.
lib/gitlab/satellite/files/delete_file_action.rb
0 → 100644
View file @
b26abe8f
require_relative
'file_action'
module
Gitlab
module
Satellite
class
DeleteFileAction
<
FileAction
# Deletes file and creates a new commit for it
#
# Returns false if committing the change fails
# Returns false if pushing from the satellite to bare repo failed or was rejected
# Returns true otherwise
def
commit!
(
content
,
commit_message
)
in_locked_and_timed_satellite
do
|
repo
|
prepare_satellite!
(
repo
)
# create target branch in satellite at the corresponding commit from bare repo
repo
.
git
.
checkout
({
raise:
true
,
timeout:
true
,
b:
true
},
ref
,
"origin/
#{
ref
}
"
)
# update the file in the satellite's working dir
file_path_in_satellite
=
File
.
join
(
repo
.
working_dir
,
file_path
)
File
.
delete
(
file_path_in_satellite
)
# add removed file
repo
.
add
(
file_path_in_satellite
)
# commit the changes
# will raise CommandFailed when commit fails
repo
.
git
.
commit
(
raise:
true
,
timeout:
true
,
a:
true
,
m:
commit_message
)
# push commit back to bare repo
# will raise CommandFailed when push fails
repo
.
git
.
push
({
raise:
true
,
timeout:
true
},
:origin
,
ref
)
# everything worked
true
end
rescue
Grit
::
Git
::
CommandFailed
=>
ex
Gitlab
::
GitLogger
.
error
(
ex
.
message
)
false
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