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
705f1558
Commit
705f1558
authored
Feb 24, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix spec
parent
38a7a5f4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
82 deletions
+26
-82
app/models/repository.rb
app/models/repository.rb
+21
-77
app/services/files/create_service.rb
app/services/files/create_service.rb
+1
-1
app/services/files/multi_service.rb
app/services/files/multi_service.rb
+3
-3
app/services/files/update_service.rb
app/services/files/update_service.rb
+1
-1
No files found.
app/models/repository.rb
View file @
705f1558
...
@@ -746,99 +746,43 @@ class Repository
...
@@ -746,99 +746,43 @@ class Repository
@tags
||=
raw_repository
.
tags
@tags
||=
raw_repository
.
tags
end
end
# rubocop:disable Metrics/ParameterLists
def
create_dir
(
user
,
path
,
**
options
)
def
create_dir
(
options
[
:user
]
=
user
user
,
path
,
options
[
:actions
]
=
[{
action: :create_dir
,
file_path:
path
}]
message
:,
branch_name
:,
author_email:
nil
,
author_name:
nil
,
start_branch_name:
nil
,
start_project:
project
)
multi_action
(
multi_action
(
**
options
)
user:
user
,
message:
message
,
branch_name:
branch_name
,
author_email:
author_email
,
author_name:
author_name
,
start_branch_name:
start_branch_name
,
start_project:
start_project
,
actions:
[{
action: :create_dir
,
file_path:
path
}])
end
end
# rubocop:enable Metrics/ParameterLists
# rubocop:disable Metrics/ParameterLists
def
create_file
(
user
,
path
,
content
,
**
options
)
def
create_file
(
options
[
:user
]
=
user
user
,
path
,
content
,
options
[
:actions
]
=
[{
action: :create
,
file_path:
path
,
content:
content
}]
message
:,
branch_name
:,
author_email:
nil
,
author_name:
nil
,
start_branch_name:
nil
,
start_project:
project
)
multi_action
(
multi_action
(
**
options
)
user:
user
,
message:
message
,
branch_name:
branch_name
,
author_email:
author_email
,
author_name:
author_name
,
start_branch_name:
start_branch_name
,
start_project:
start_project
,
actions:
[{
action: :create
,
file_path:
path
,
content:
content
}])
end
end
# rubocop:enable Metrics/ParameterLists
# rubocop:disable Metrics/ParameterLists
def
update_file
(
user
,
path
,
content
,
**
options
)
def
update_file
(
previous_path
=
options
.
delete
(
:previous_path
)
user
,
path
,
content
,
action
=
previous_path
&&
previous_path
!=
path
?
:move
:
:update
message
:,
branch_name
:,
previous_path:
nil
,
author_email:
nil
,
author_name:
nil
,
options
[
:user
]
=
user
start_branch_name:
nil
,
start_project:
project
)
options
[
:actions
]
=
[{
action:
action
,
file_path:
path
,
previous_path:
previous_path
,
content:
content
}]
action
=
if
previous_path
&&
previous_path
!=
path
:move
multi_action
(
**
options
)
else
:update
end
multi_action
(
user:
user
,
message:
message
,
branch_name:
branch_name
,
author_email:
author_email
,
author_name:
author_name
,
start_branch_name:
start_branch_name
,
start_project:
start_project
,
actions:
[{
action:
action
,
file_path:
path
,
content:
content
,
previous_path:
previous_path
}])
end
end
# rubocop:enable Metrics/ParameterLists
# rubocop:disable Metrics/ParameterLists
def
delete_file
(
user
,
path
,
**
options
)
def
delete_file
(
options
[
:user
]
=
user
user
,
path
,
options
[
:actions
]
=
[{
action: :delete
,
file_path:
path
}]
message
:,
branch_name
:,
author_email:
nil
,
author_name:
nil
,
start_branch_name:
nil
,
start_project:
project
)
multi_action
(
multi_action
(
**
options
)
user:
user
,
message:
message
,
branch_name:
branch_name
,
author_email:
author_email
,
author_name:
author_name
,
start_branch_name:
start_branch_name
,
start_project:
start_project
,
actions:
[{
action: :delete
,
file_path:
path
}])
end
end
# rubocop:enable Metrics/ParameterLists
# rubocop:disable Metrics/ParameterLists
# rubocop:disable Metrics/ParameterLists
def
multi_action
(
def
multi_action
(
user
:,
branch_name
:,
message
:,
actions
:,
user
:,
branch_name
:,
message
:,
actions
:,
author_email:
nil
,
author_name:
nil
,
author_email:
nil
,
author_name:
nil
,
start_branch_name:
nil
,
start_project:
project
)
start_branch_name:
nil
,
start_project:
project
)
GitOperationService
.
new
(
user
,
self
).
with_branch
(
GitOperationService
.
new
(
user
,
self
).
with_branch
(
branch_name
,
branch_name
,
start_branch_name:
start_branch_name
,
start_branch_name:
start_branch_name
,
...
...
app/services/files/create_service.rb
View file @
705f1558
...
@@ -16,7 +16,7 @@ module Files
...
@@ -16,7 +16,7 @@ module Files
def
validate
def
validate
super
super
if
@file_content
.
empty
?
if
@file_content
.
nil
?
raise_error
(
"You must provide content."
)
raise_error
(
"You must provide content."
)
end
end
...
...
app/services/files/multi_service.rb
View file @
705f1558
...
@@ -21,7 +21,7 @@ module Files
...
@@ -21,7 +21,7 @@ module Files
def
validate
def
validate
super
super
params
[
:actions
].
each_with_index
do
|
action
,
index
|
params
[
:actions
].
each_with_index
do
|
action
,
index
|
if
ACTIONS
.
include?
(
action
[
:action
].
to_s
)
if
ACTIONS
.
include?
(
action
[
:action
].
to_s
)
action
[
:action
]
=
action
[
:action
].
to_sym
action
[
:action
]
=
action
[
:action
].
to_sym
...
@@ -102,13 +102,13 @@ module Files
...
@@ -102,13 +102,13 @@ module Files
raise_error
(
"Your changes could not be committed because a file with the name `
#{
action
[
:file_path
]
}
` already exists."
)
raise_error
(
"Your changes could not be committed because a file with the name `
#{
action
[
:file_path
]
}
` already exists."
)
end
end
if
action
[
:content
].
empty
?
if
action
[
:content
].
nil
?
raise_error
(
"You must provide content."
)
raise_error
(
"You must provide content."
)
end
end
end
end
def
validate_update
(
action
)
def
validate_update
(
action
)
if
action
[
:content
].
empty
?
if
action
[
:content
].
nil
?
raise_error
(
"You must provide content."
)
raise_error
(
"You must provide content."
)
end
end
...
...
app/services/files/update_service.rb
View file @
705f1558
...
@@ -18,7 +18,7 @@ module Files
...
@@ -18,7 +18,7 @@ module Files
def
validate
def
validate
super
super
if
@file_content
.
empty
?
if
@file_content
.
nil
?
raise_error
(
"You must provide content."
)
raise_error
(
"You must provide content."
)
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