Commit b58d85c3 authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

ok

parent ec2f5263
...@@ -1131,12 +1131,12 @@ module API ...@@ -1131,12 +1131,12 @@ module API
author: { author: {
name: commit.author_name, name: commit.author_name,
email: commit.author_email, email: commit.author_email,
date: "2011-04-14T16:00:49Z" date: commit.authored_date.iso8601(3)
}, },
committer: { committer: {
name: commit.committer_name, name: commit.committer_name,
email: commit.committer_email, email: commit.committer_email,
date: "2011-04-14T16:00:49Z"#commit.committed_date.iso8601(3) date: commit.committed_date.iso8601(3)
}, },
message: commit.safe_message message: commit.safe_message
} }
......
...@@ -5,6 +5,43 @@ module API ...@@ -5,6 +5,43 @@ module API
allow_access_with_scope :read_user, if: -> (request) { request.get? } allow_access_with_scope :read_user, if: -> (request) { request.get? }
resource :users do
get ':id' do
present {
"login" => "oswaldo",
"id" => 1,
"avatar_url" => "https://github.com/images/error/octocat_happy.gif",
"gravatar_id" => "",
"url" => "https://api.github.com/users/octocat",
"html_url" => "https://github.com/octocat",
"followers_url" => "https://api.github.com/users/octocat/followers",
"following_url" => "https://api.github.com/users/octocat/following{/other_user}",
"gists_url" => "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url" => "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url" => "https://api.github.com/users/octocat/subscriptions",
"organizations_url" => "https://api.github.com/users/octocat/orgs",
"repos_url" => "https://api.github.com/users/octocat/repos",
"events_url" => "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url" => "https://api.github.com/users/octocat/received_events",
"type" => "User",
"site_admin" => false,
"name" => "monalisa octocat",
"company" => "GitHub",
"blog" => "https://github.com/blog",
"location" => "San Francisco",
"email" => "octocat@github.com",
"hireable" => false,
"bio" => "There once was...",
"public_repos" => 2,
"public_gists" => 1,
"followers" => 20,
"following" => 0,
"created_at" => "2008-01-14T04:33:35Z",
"updated_at" => "2008-01-14T04:33:35Z"
}
end
end
resource :users, requirements: { uid: /[0-9]*/, id: /[0-9]*/ } do resource :users, requirements: { uid: /[0-9]*/, id: /[0-9]*/ } do
before do before do
authenticate_non_get! authenticate_non_get!
......
...@@ -17,6 +17,10 @@ module API ...@@ -17,6 +17,10 @@ module API
resource :users do resource :users do
get ':namespace/repos' do get ':namespace/repos' do
projs = ::API::Entities::Github::Repository.represent(current_user.authorized_projects).as_json
Rails.logger.info("PROJS JSON: #{projs}")
present paginate(current_user.authorized_projects), with: ::API::Entities::Github::Repository present paginate(current_user.authorized_projects), with: ::API::Entities::Github::Repository
end end
end end
...@@ -25,6 +29,7 @@ module API ...@@ -25,6 +29,7 @@ module API
requires :namespace, type: String requires :namespace, type: String
requires :project, type: String requires :project, type: String
end end
resource :repos do resource :repos do
get ':namespace/:project/branches' do get ':namespace/:project/branches' do
namespace = params[:namespace] namespace = params[:namespace]
...@@ -49,13 +54,10 @@ module API ...@@ -49,13 +54,10 @@ module API
requires :project, type: String requires :project, type: String
end end
get ':namespace/:project/commits/:sha' do get ':namespace/:project/commits/:sha' do
Rails.logger.info("FETCHING COMMITS FOR #{params[:namespace]}/#{params[:project]} [hardcoded]")
namespace = params[:namespace] namespace = params[:namespace]
project = params[:project] project = params[:project]
user_project = find_project!("#{namespace}/#{project}") user_project = find_project!("#{namespace}/#{project}")
# sent :sha HAS to match with the returned sha on commit in order to succeed
commit = user_project.commit(params[:sha]) commit = user_project.commit(params[:sha])
not_found! 'Commit' unless commit not_found! 'Commit' unless commit
...@@ -67,7 +69,7 @@ module API ...@@ -67,7 +69,7 @@ module API
# hash = # hash =
# { # {
# "sha" => "357fb168fc667ef07a3303e4bb528fbcb2147430", # "sha" => "b0ee36f0a5356c092a5d4913f3523db93a1db565",
# "commit" => { # "commit" => {
# "author" => { # "author" => {
# "name" => "oswaksd", # "name" => "oswaksd",
...@@ -79,7 +81,7 @@ module API ...@@ -79,7 +81,7 @@ module API
# "email" => "oswluizf@gmail.com", # "email" => "oswluizf@gmail.com",
# "date" => "2011-04-14T16:00:49Z" # "date" => "2011-04-14T16:00:49Z"
# }, # },
# "message" => "hardcoded GL-2", # "message" => "Fix all the bugs GL-2",
# }, # },
# "author" => { # "author" => {
# "login" => "oswaldo", # "login" => "oswaldo",
...@@ -91,7 +93,7 @@ module API ...@@ -91,7 +93,7 @@ module API
# }, # },
# "parents" => [ # "parents" => [
# { # {
# "sha" => "357fb168fc667ef07a3303e4bb528fbcb2147430" # "sha" => "e7d7eb49018d7bffa6be52586c518974778965c5"
# } # }
# ], # ],
# "files" => [ # "files" => [
...@@ -106,7 +108,7 @@ module API ...@@ -106,7 +108,7 @@ module API
# ] # ]
# } # }
#present hash # present hash
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment