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
ce8fc586
Commit
ce8fc586
authored
Sep 30, 2020
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix verifying LFS uploads with GitHub
The verify action, but not upload or batch, requires a user agent.
parent
7d27bb49
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
5 deletions
+17
-5
changelogs/unreleased/254281-add-user-agent-to-git-lfs-client.yml
...gs/unreleased/254281-add-user-agent-to-git-lfs-client.yml
+5
-0
lib/gitlab/lfs/client.rb
lib/gitlab/lfs/client.rb
+5
-2
spec/lib/gitlab/lfs/client_spec.rb
spec/lib/gitlab/lfs/client_spec.rb
+7
-3
No files found.
changelogs/unreleased/254281-add-user-agent-to-git-lfs-client.yml
0 → 100644
View file @
ce8fc586
---
title
:
Fix verifying LFS uploads with GitHub
merge_request
:
43852
author
:
type
:
fixed
lib/gitlab/lfs/client.rb
View file @
ce8fc586
...
...
@@ -7,9 +7,11 @@ module Gitlab
# * https://github.com/git-lfs/git-lfs/blob/master/docs/api/basic-transfers.md
class
Client
GIT_LFS_CONTENT_TYPE
=
'application/vnd.git-lfs+json'
GIT_LFS_USER_AGENT
=
"GitLab
#{
Gitlab
::
VERSION
}
LFS client"
DEFAULT_HEADERS
=
{
'Accept'
=>
GIT_LFS_CONTENT_TYPE
,
'Content-Type'
=>
GIT_LFS_CONTENT_TYPE
'Content-Type'
=>
GIT_LFS_CONTENT_TYPE
,
'User-Agent'
=>
GIT_LFS_USER_AGENT
}.
freeze
attr_reader
:base_url
...
...
@@ -53,7 +55,8 @@ module Gitlab
body_stream:
file
,
headers:
{
'Content-Length'
=>
object
.
size
.
to_s
,
'Content-Type'
=>
'application/octet-stream'
'Content-Type'
=>
'application/octet-stream'
,
'User-Agent'
=>
GIT_LFS_USER_AGENT
}.
merge
(
upload_action
[
'header'
]
||
{})
}
...
...
spec/lib/gitlab/lfs/client_spec.rb
View file @
ce8fc586
...
...
@@ -8,6 +8,7 @@ RSpec.describe Gitlab::Lfs::Client do
let
(
:password
)
{
'password'
}
let
(
:credentials
)
{
{
user:
username
,
password:
password
,
auth_method:
'password'
}
}
let
(
:git_lfs_content_type
)
{
'application/vnd.git-lfs+json'
}
let
(
:git_lfs_user_agent
)
{
"GitLab
#{
Gitlab
::
VERSION
}
LFS client"
}
let
(
:basic_auth_headers
)
do
{
'Authorization'
=>
"Basic
#{
Base64
.
strict_encode64
(
"
#{
username
}
:
#{
password
}
"
)
}
"
}
...
...
@@ -91,7 +92,8 @@ RSpec.describe Gitlab::Lfs::Client do
headers
=
{
'Accept'
=>
git_lfs_content_type
,
'Content-Type'
=>
git_lfs_content_type
'Content-Type'
=>
git_lfs_content_type
,
'User-Agent'
=>
git_lfs_user_agent
}.
merge
(
headers
)
stub_request
(
:post
,
base_url
+
'/info/lfs/objects/batch'
).
with
(
body:
body
,
headers:
headers
)
...
...
@@ -156,7 +158,8 @@ RSpec.describe Gitlab::Lfs::Client do
def
stub_upload
(
object
:,
headers
:)
headers
=
{
'Content-Type'
=>
'application/octet-stream'
,
'Content-Length'
=>
object
.
size
.
to_s
'Content-Length'
=>
object
.
size
.
to_s
,
'User-Agent'
=>
git_lfs_user_agent
}.
merge
(
headers
)
stub_request
(
:put
,
upload_action
[
'href'
]).
with
(
...
...
@@ -209,7 +212,8 @@ RSpec.describe Gitlab::Lfs::Client do
def
stub_verify
(
object
:,
headers
:)
headers
=
{
'Accept'
=>
git_lfs_content_type
,
'Content-Type'
=>
git_lfs_content_type
'Content-Type'
=>
git_lfs_content_type
,
'User-Agent'
=>
git_lfs_user_agent
}.
merge
(
headers
)
stub_request
(
:post
,
verify_action
[
'href'
]).
with
(
...
...
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