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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
1461199d
Commit
1461199d
authored
Apr 08, 2021
by
Aishwarya Subramanian
Committed by
Nick Thomas
Apr 08, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make ref parameter optional in get raw file api
parent
37e20624
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
5 deletions
+25
-5
changelogs/unreleased/fix-compliance-pipeline-validation.yml
changelogs/unreleased/fix-compliance-pipeline-validation.yml
+5
-0
doc/api/repository_files.md
doc/api/repository_files.md
+2
-2
ee/app/assets/javascripts/groups/settings/compliance_frameworks/utils.js
...avascripts/groups/settings/compliance_frameworks/utils.js
+1
-1
lib/api/files.rb
lib/api/files.rb
+2
-2
spec/requests/api/files_spec.rb
spec/requests/api/files_spec.rb
+15
-0
No files found.
changelogs/unreleased/fix-compliance-pipeline-validation.yml
0 → 100644
View file @
1461199d
---
title
:
Make ref parameter optional in get raw file api
merge_request
:
58787
author
:
type
:
changed
doc/api/repository_files.md
View file @
1461199d
...
...
@@ -168,8 +168,8 @@ curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/a
Parameters:
-
`file_path`
(required) - URL encoded full path to new file
. Ex. lib%2Fclass%2Erb
-
`ref`
(
required) - The name of branch, tag or commit
-
`file_path`
(required) - URL encoded full path to new file
, such as lib%2Fclass%2Erb.
-
`ref`
(
optional) - The name of branch, tag or commit. Default is the
`HEAD`
of the project.
NOTE:
Like
[
Get file from repository
](
repository_files.md#get-file-from-repository
)
you can use
`HEAD`
to get just file metadata.
...
...
ee/app/assets/javascripts/groups/settings/compliance_frameworks/utils.js
View file @
1461199d
...
...
@@ -45,7 +45,7 @@ export const fetchPipelineConfigurationFileExists = async (path) => {
}
try
{
const
{
status
}
=
await
Api
.
getRawFile
(
`
${
group
}
/
${
project
}
`
,
file
);
const
{
status
}
=
await
Api
.
getRawFile
(
`
${
group
}
/
${
project
}
`
,
file
,
{
ref
:
undefined
}
);
return
status
===
httpStatus
.
OK
;
}
catch
(
e
)
{
...
...
lib/api/files.rb
View file @
1461199d
...
...
@@ -113,7 +113,7 @@ module API
desc
'Get raw file metadata from repository'
params
do
requires
:file_path
,
type:
String
,
file_path:
true
,
desc:
'The url encoded path to the file. Ex. lib%2Fclass%2Erb'
requires
:ref
,
type:
String
,
desc:
'The name of branch, tag or commit'
,
allow_blank:
false
optional
:ref
,
type:
String
,
desc:
'The name of branch, tag or commit'
,
allow_blank:
false
end
head
":id/repository/files/:file_path/raw"
,
requirements:
FILE_ENDPOINT_REQUIREMENTS
do
assign_file_vars!
...
...
@@ -124,7 +124,7 @@ module API
desc
'Get raw file contents from the repository'
params
do
requires
:file_path
,
type:
String
,
file_path:
true
,
desc:
'The url encoded path to the file. Ex. lib%2Fclass%2Erb'
requires
:ref
,
type:
String
,
desc:
'The name of branch, tag
commit'
,
allow_blank:
false
optional
:ref
,
type:
String
,
desc:
'The name of branch, tag or
commit'
,
allow_blank:
false
end
get
":id/repository/files/:file_path/raw"
,
requirements:
FILE_ENDPOINT_REQUIREMENTS
do
assign_file_vars!
...
...
spec/requests/api/files_spec.rb
View file @
1461199d
...
...
@@ -517,6 +517,21 @@ RSpec.describe API::Files do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
context
'when ref is not provided'
do
before
do
stub_application_setting
(
default_branch_name:
'main'
)
end
it
'returns response :ok'
,
:aggregate_failures
do
url
=
route
(
file_path
)
+
"/raw"
expect
(
Gitlab
::
Workhorse
).
to
receive
(
:send_git_blob
)
get
api
(
url
,
current_user
),
params:
{}
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
it
'returns raw file info for files with dots'
do
url
=
route
(
'.gitignore'
)
+
"/raw"
expect
(
Gitlab
::
Workhorse
).
to
receive
(
:send_git_blob
)
...
...
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