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
Tatuya Kamada
gitlab-ce
Commits
5a586f36
Commit
5a586f36
authored
Mar 12, 2016
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Merge branch 'support-go-subpackages' into 'master'
This reverts merge request !3191
parent
826bc72c
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
16 additions
and
82 deletions
+16
-82
CHANGELOG
CHANGELOG
+0
-1
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+11
-0
app/views/projects/go_import.html.haml
app/views/projects/go_import.html.haml
+5
-0
config/initializers/go_get.rb
config/initializers/go_get.rb
+0
-1
lib/gitlab/middleware/go.rb
lib/gitlab/middleware/go.rb
+0
-50
spec/lib/gitlab/middleware/go_spec.rb
spec/lib/gitlab/middleware/go_spec.rb
+0
-30
No files found.
CHANGELOG
View file @
5a586f36
Please view this file on the master branch, on stable branches it's out of date.
v 8.6.0 (unreleased)
- Support Golang subpackage fetching (Stan Hu)
- Contributions to forked projects are included in calendar
- Improve the formatting for the user page bio (Connor Shea)
- Removed the default password from the initial admin account created during
...
...
app/controllers/projects_controller.rb
View file @
5a586f36
class
ProjectsController
<
ApplicationController
include
ExtractsPath
prepend_before_action
:render_go_import
,
only:
[
:show
]
skip_before_action
:authenticate_user!
,
only:
[
:show
,
:activity
]
before_action
:project
,
except:
[
:new
,
:create
]
before_action
:repository
,
except:
[
:new
,
:create
]
...
...
@@ -241,6 +242,16 @@ class ProjectsController < ApplicationController
end
end
def
render_go_import
return
unless
params
[
"go-get"
]
==
"1"
@namespace
=
params
[
:namespace_id
]
@id
=
params
[
:project_id
]
||
params
[
:id
]
@id
=
@id
.
gsub
(
/\.git\Z/
,
""
)
render
"go_import"
,
layout:
false
end
def
repo_exists?
project
.
repository_exists?
&&
!
project
.
empty_repo?
end
...
...
app/views/projects/go_import.html.haml
0 → 100644
View file @
5a586f36
!!! 5
%html
%head
-
web_url
=
[
Gitlab
.
config
.
gitlab
.
url
,
@namespace
,
@id
].
join
(
'/'
)
%meta
{
name:
"go-import"
,
content:
"#{web_url.split('://')[1]} git #{web_url}.git"
}
config/initializers/go_get.rb
deleted
100644 → 0
View file @
826bc72c
Rails
.
application
.
config
.
middleware
.
use
(
Gitlab
::
Middleware
::
Go
)
lib/gitlab/middleware/go.rb
deleted
100644 → 0
View file @
826bc72c
# A dumb middleware that returns a Go HTML document if the go-get=1 query string
# is used irrespective if the namespace/project exists
module
Gitlab
module
Middleware
class
Go
def
initialize
(
app
)
@app
=
app
end
def
call
(
env
)
request
=
Rack
::
Request
.
new
(
env
)
if
go_request?
(
request
)
render_go_doc
(
request
)
else
@app
.
call
(
env
)
end
end
private
def
render_go_doc
(
request
)
body
=
go_body
(
request
)
response
=
Rack
::
Response
.
new
(
body
,
200
,
{
'Content-Type'
=>
'text/html'
})
response
.
finish
end
def
go_request?
(
request
)
request
[
"go-get"
].
to_i
==
1
&&
request
.
env
[
"PATH_INFO"
].
present?
end
def
go_body
(
request
)
base_url
=
Gitlab
.
config
.
gitlab
.
url
# Go subpackages may be in the form of namespace/project/path1/path2/../pathN
# We can just ignore the paths and leave the namespace/project
path_info
=
request
.
env
[
"PATH_INFO"
]
path_info
.
sub!
(
/^\//
,
''
)
project_path
=
path_info
.
split
(
'/'
).
first
(
2
).
join
(
'/'
)
request_url
=
URI
.
join
(
base_url
,
project_path
)
domain_path
=
strip_url
(
request_url
.
to_s
)
"<!DOCTYPE html><html><head><meta content='
#{
domain_path
}
git
#{
request_url
}
.git' name='go-import'></head></html>
\n
"
;
end
def
strip_url
(
url
)
url
.
gsub
(
/\Ahttps?:\/\//
,
''
)
end
end
end
end
spec/lib/gitlab/middleware/go_spec.rb
deleted
100644 → 0
View file @
826bc72c
require
'spec_helper'
describe
Gitlab
::
Middleware
::
Go
,
lib:
true
do
let
(
:app
)
{
double
(
:app
)
}
let
(
:middleware
)
{
described_class
.
new
(
app
)
}
describe
'#call'
do
describe
'when go-get=0'
do
it
'skips go-import generation'
do
env
=
{
'rack.input'
=>
''
,
'QUERY_STRING'
=>
'go-get=0'
}
expect
(
app
).
to
receive
(
:call
).
with
(
env
).
and_return
(
'no-go'
)
middleware
.
call
(
env
)
end
end
describe
'when go-get=1'
do
it
'returns a document'
do
env
=
{
'rack.input'
=>
''
,
'QUERY_STRING'
=>
'go-get=1'
,
'PATH_INFO'
=>
'/group/project/path'
}
resp
=
middleware
.
call
(
env
)
expect
(
resp
[
0
]).
to
eq
(
200
)
expect
(
resp
[
1
][
'Content-Type'
]).
to
eq
(
'text/html'
)
expected_body
=
"<!DOCTYPE html><html><head><meta content='localhost/group/project git http://localhost/group/project.git' name='go-import'></head></html>
\n
"
expect
(
resp
[
2
].
body
).
to
eq
([
expected_body
])
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