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
Léo-Paul Géneau
gitlab-ce
Commits
ffb0ad93
Commit
ffb0ad93
authored
Aug 29, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:gitlabhq/gitlabhq
parents
255d6d8b
079d3a5d
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
100 additions
and
23 deletions
+100
-23
app/views/profiles/keys/_form.html.haml
app/views/profiles/keys/_form.html.haml
+1
-1
doc/api/repositories.md
doc/api/repositories.md
+27
-2
lib/api/repositories.rb
lib/api/repositories.rb
+20
-4
lib/tasks/gitlab/check.rake
lib/tasks/gitlab/check.rake
+8
-8
spec/requests/api/repositories_spec.rb
spec/requests/api/repositories_spec.rb
+44
-8
No files found.
app/views/profiles/keys/_form.html.haml
View file @
ffb0ad93
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
=
f
.
label
:key
=
f
.
label
:key
.controls
.controls
%p
.light
%p
.light
Paste your public key here. Read more about how
generate it
#{
link_to
"here"
,
help_ssh_path
}
Paste your public key here. Read more about how
to generate a key on
#{
link_to
"the SSH help page"
,
help_ssh_path
}
.
=
f
.
text_area
:key
,
class:
"input-xxlarge thin_area"
=
f
.
text_area
:key
,
class:
"input-xxlarge thin_area"
...
...
doc/api/repositories.md
View file @
ffb0ad93
...
@@ -239,12 +239,37 @@ Parameters:
...
@@ -239,12 +239,37 @@ Parameters:
]
]
```
```
## Get a single commit
Get a specific commit identified by the commit hash or name of a branch or tag.
```
GET /projects/:id/repository/commits/:sha
```
Parameters:
+
`id`
(required) - The ID of a project
+
`sha`
(required) - The commit hash or name of a repository branch or tag
```
json
{
"id"
:
"6104942438c14ec7bd21c6cd5bd995272b3faff6"
,
"short_id"
:
"6104942438c"
,
"title"
:
"Sanitize for network graph"
,
"author_name"
:
"randx"
,
"author_email"
:
"dmitriy.zaporozhets@gmail.com"
,
"created_at"
:
"2012-09-20T09:06:12+03:00"
}
```
## Get the diff of a commit
## Get the diff of a commit
Get the diff of a commit in a project.
Get the diff of a commit in a project.
```
```
GET /projects/:id/repository/commit
/:sha
GET /projects/:id/repository/commit
s/:sha/diff
```
```
Parameters:
Parameters:
...
@@ -323,7 +348,7 @@ Parameters:
...
@@ -323,7 +348,7 @@ Parameters:
Get the raw file contents for a file.
Get the raw file contents for a file.
```
```
GET /projects/:id/repository/
commits/:sha/blob
GET /projects/:id/repository/
blobs/:sha
```
```
Parameters:
Parameters:
...
...
lib/api/repositories.rb
View file @
ffb0ad93
...
@@ -106,13 +106,29 @@ module API
...
@@ -106,13 +106,29 @@ module API
#
#
# Parameters:
# Parameters:
# id (required) - The ID of a project
# id (required) - The ID of a project
# sha (required) - The commit hash or name of a repository branch or tag
# Example Request:
# GET /projects/:id/repository/commits/:sha
get
":id/repository/commits/:sha"
do
authorize!
:download_code
,
user_project
sha
=
params
[
:sha
]
commit
=
user_project
.
repository
.
commit
(
sha
)
not_found!
"Commit"
unless
commit
present
commit
,
with:
Entities
::
RepoCommit
end
# Get the diff for a specific commit of a project
#
# Parameters:
# id (required) - The ID of a project
# sha (required) - The commit or branch name
# sha (required) - The commit or branch name
# Example Request:
# Example Request:
# GET /projects/:id/repository/commit
/:sha
# GET /projects/:id/repository/commit
s/:sha/diff
get
":id/repository/commit
/:sha
"
do
get
":id/repository/commit
s/:sha/diff
"
do
authorize!
:download_code
,
user_project
authorize!
:download_code
,
user_project
sha
=
params
[
:sha
]
sha
=
params
[
:sha
]
result
=
CommitLoadContext
.
new
(
user_project
,
current_user
,
{
id:
sha
}).
execute
result
=
CommitLoadContext
.
new
(
user_project
,
current_user
,
{
id:
sha
}).
execute
not_found!
"Commit"
unless
result
[
:commit
]
result
[
:commit
].
diffs
result
[
:commit
].
diffs
end
end
...
@@ -148,8 +164,8 @@ module API
...
@@ -148,8 +164,8 @@ module API
# sha (required) - The commit or branch name
# sha (required) - The commit or branch name
# filepath (required) - The path to the file to display
# filepath (required) - The path to the file to display
# Example Request:
# Example Request:
# GET /projects/:id/repository/
commits/:sha/blob
# GET /projects/:id/repository/
blobs/:sha
get
":id/repository/commits/:sha/blob"
do
get
[
":id/repository/blobs/:sha"
,
":id/repository/commits/:sha/blob"
]
do
authorize!
:download_code
,
user_project
authorize!
:download_code
,
user_project
required_attributes!
[
:filepath
]
required_attributes!
[
:filepath
]
...
...
lib/tasks/gitlab/check.rake
View file @
ffb0ad93
...
@@ -374,8 +374,8 @@ namespace :gitlab do
...
@@ -374,8 +374,8 @@ namespace :gitlab do
check_repo_base_is_not_symlink
check_repo_base_is_not_symlink
check_repo_base_user_and_group
check_repo_base_user_and_group
check_repo_base_permissions
check_repo_base_permissions
check_
post_receiv
e_hook_is_up_to_date
check_
updat
e_hook_is_up_to_date
check_repos_
post_receiv
e_hooks_is_link
check_repos_
updat
e_hooks_is_link
finished_checking
"GitLab Shell"
finished_checking
"GitLab Shell"
end
end
...
@@ -385,10 +385,10 @@ namespace :gitlab do
...
@@ -385,10 +385,10 @@ namespace :gitlab do
########################
########################
def
check_
post_receiv
e_hook_is_up_to_date
def
check_
updat
e_hook_is_up_to_date
print
"
post-receiv
e hook up-to-date? ... "
print
"
updat
e hook up-to-date? ... "
hook_file
=
"
post-receiv
e"
hook_file
=
"
updat
e"
gitlab_shell_hooks_path
=
Gitlab
.
config
.
gitlab_shell
.
hooks_path
gitlab_shell_hooks_path
=
Gitlab
.
config
.
gitlab_shell
.
hooks_path
gitlab_shell_hook_file
=
File
.
join
(
gitlab_shell_hooks_path
,
hook_file
)
gitlab_shell_hook_file
=
File
.
join
(
gitlab_shell_hooks_path
,
hook_file
)
gitlab_shell_ssh_user
=
Gitlab
.
config
.
gitlab_shell
.
ssh_user
gitlab_shell_ssh_user
=
Gitlab
.
config
.
gitlab_shell
.
ssh_user
...
@@ -494,10 +494,10 @@ namespace :gitlab do
...
@@ -494,10 +494,10 @@ namespace :gitlab do
end
end
end
end
def
check_repos_
post_receiv
e_hooks_is_link
def
check_repos_
updat
e_hooks_is_link
print
"
post-receiv
e hooks in repos are links: ... "
print
"
updat
e hooks in repos are links: ... "
hook_file
=
"
post-receiv
e"
hook_file
=
"
updat
e"
gitlab_shell_hooks_path
=
Gitlab
.
config
.
gitlab_shell
.
hooks_path
gitlab_shell_hooks_path
=
Gitlab
.
config
.
gitlab_shell
.
hooks_path
gitlab_shell_hook_file
=
File
.
join
(
gitlab_shell_hooks_path
,
hook_file
)
gitlab_shell_hook_file
=
File
.
join
(
gitlab_shell_hooks_path
,
hook_file
)
gitlab_shell_ssh_user
=
Gitlab
.
config
.
gitlab_shell
.
ssh_user
gitlab_shell_ssh_user
=
Gitlab
.
config
.
gitlab_shell
.
ssh_user
...
...
spec/requests/api/repositories_spec.rb
View file @
ffb0ad93
...
@@ -112,23 +112,51 @@ describe API::API do
...
@@ -112,23 +112,51 @@ describe API::API do
end
end
end
end
describe
"GET /projects:id/repository/commit/:sha"
do
describe
"GET /projects:id/repository/commits/:sha"
do
context
"authorized user"
do
it
"should return a commit by sha"
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/
#{
project
.
repository
.
commit
.
id
}
"
,
user
)
response
.
status
.
should
==
200
json_response
[
'id'
].
should
==
project
.
repository
.
commit
.
id
json_response
[
'title'
].
should
==
project
.
repository
.
commit
.
title
end
it
"should return a 404 error if not found"
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/invalid_sha"
,
user
)
response
.
status
.
should
==
404
end
end
context
"unauthorized user"
do
it
"should not return the selected commit"
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/
#{
project
.
repository
.
commit
.
id
}
"
)
response
.
status
.
should
==
401
end
end
end
describe
"GET /projects:id/repository/commits/:sha/diff"
do
context
"authorized user"
do
context
"authorized user"
do
before
{
project
.
team
<<
[
user2
,
:reporter
]
}
before
{
project
.
team
<<
[
user2
,
:reporter
]
}
it
"should return the diff of the selected commit"
do
it
"should return the diff of the selected commit"
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/commit
/
#{
project
.
repository
.
commit
.
id
}
"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/repository/commit
s/
#{
project
.
repository
.
commit
.
id
}
/diff
"
,
user
)
response
.
status
.
should
==
200
response
.
status
.
should
==
200
json_response
.
should
be_an
Array
json_response
.
should
be_an
Array
json_response
.
length
.
should
>=
1
json_response
.
length
.
should
>=
1
json_response
.
first
.
keys
.
should
include
"diff"
json_response
.
first
.
keys
.
should
include
"diff"
end
end
it
"should return a 404 error if invalid commit"
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/invalid_sha/diff"
,
user
)
response
.
status
.
should
==
404
end
end
end
context
"unauthorized user"
do
context
"unauthorized user"
do
it
"should not return the diff of the selected commit"
do
it
"should not return the diff of the selected commit"
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/commit
/
#{
project
.
repository
.
commit
.
id
}
"
)
get
api
(
"/projects/
#{
project
.
id
}
/repository/commit
s/
#{
project
.
repository
.
commit
.
id
}
/diff
"
)
response
.
status
.
should
==
401
response
.
status
.
should
==
401
end
end
end
end
...
@@ -157,25 +185,33 @@ describe API::API do
...
@@ -157,25 +185,33 @@ describe API::API do
end
end
end
end
describe
"GET /projects/:id/repository/
commits/:sha/blob
"
do
describe
"GET /projects/:id/repository/
blobs/:sha
"
do
it
"should get the raw file contents"
do
it
"should get the raw file contents"
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/
commits/master/blob
?filepath=README.md"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/repository/
blobs/master
?filepath=README.md"
,
user
)
response
.
status
.
should
==
200
response
.
status
.
should
==
200
end
end
it
"should return 404 for invalid branch_name"
do
it
"should return 404 for invalid branch_name"
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/
commits/invalid_branch_name/blob
?filepath=README.md"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/repository/
blobs/invalid_branch_name
?filepath=README.md"
,
user
)
response
.
status
.
should
==
404
response
.
status
.
should
==
404
end
end
it
"should return 404 for invalid file"
do
it
"should return 404 for invalid file"
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/
commits/master/blob
?filepath=README.invalid"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/repository/
blobs/master
?filepath=README.invalid"
,
user
)
response
.
status
.
should
==
404
response
.
status
.
should
==
404
end
end
it
"should return a 400 error if filepath is missing"
do
it
"should return a 400 error if filepath is missing"
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/
commits/master/blob
"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/repository/
blobs/master
"
,
user
)
response
.
status
.
should
==
400
response
.
status
.
should
==
400
end
end
end
end
describe
"GET /projects/:id/repository/commits/:sha/blob"
do
it
"should get the raw file contents"
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/master/blob?filepath=README.md"
,
user
)
response
.
status
.
should
==
200
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