Api blob contents
Created by: punkisdead
I added a couple of methods to the projects API.
- Get the details about a single branch
- Retrieve the raw contents for a file
Let me know what you think.
Regards, Jeremy Anderson
Merge request reports
Activity
Created by: punkisdead
I needed to make sure grape was using at least version 0.2.1 because of the introduction of the "content_type" function. Then I also ran into a problem with the newer version of rake, and per a suggestion from @dhh himself on twitter, I rolled it back to 0.8.7.
I'll rebase it against master tonight.
--Jeremy
On Jul 27, 2012, at 5:30 PM, Nihad Abbasov reply@reply.github.com wrote:
Thanks. I'll give it a closer look after this weekend.
Please rebase it against master. Why Gemfile is changed?
Reply to this email directly or view it on GitHub: https://github.com/gitlabhq/gitlabhq/pull/1157#issuecomment-7316729
By Administrator on 2012-07-28T02:14:42 (imported from GitLab project)
By Administrator on 2012-07-28T02:14:42 (imported from GitLab)
Created by: dzaporozhets
@punkisdead Thank you for PR. @narkoz will review it but I have 2 problems with:
- Gemfile.lock has a lot of changes. We should not make gem updates & feature in one PR. Please rollback gems updates.
- Can you provide a real reason why Rake was downgraded, please?
By Administrator on 2012-07-28T14:35:45 (imported from GitLab project)
By Administrator on 2012-07-28T14:35:45 (imported from GitLab)
Created by: punkisdead
I had some error messages that led me to this post by Dave Chelimsky (http://blog.davidchelimsky.net/2011/05/28/rake-09-and-gem-version-constraints/). I know it's older, but it's what fixed my issue. The Grape API gem needs to be at least 0.2.1 as one of the functions I wrote requires the "content_type" function as I mentioned earlier, so I can change the mime-type of the response.
By Administrator on 2012-07-28T18:34:10 (imported from GitLab project)
By Administrator on 2012-07-28T18:34:10 (imported from GitLab)
Created by: dzaporozhets
I really have no time to read. Can you explain in few words? Cause I still dont understand how rake 09 can cause problems in your PR feature
By Administrator on 2012-07-28T20:34:36 (imported from GitLab project)
By Administrator on 2012-07-28T20:34:36 (imported from GitLab)
33 33 present user_project.repo.heads.sort_by(&:name), :with => Entities::RepoObject 34 34 end 35 35 36 # Get a single branch 37 # 38 # Parameters: 39 # id (required) - The ID or code name of a project 40 # branch_id (required) - The name of the branch 41 # Example Request: 42 # GET /projects/:id/repository/branches/:branch_id 43 get ":id/repository/branches/:branch_id" do 44 @branch = user_project.repo.heads.find { |item| item.name == params[:branch_id] } 45 present @branch, :with => Entities::RepoObject 131 143 @snippet = user_project.snippets.find(params[:snippet_id]) 132 144 present @snippet.content 133 145 end 146 147 # Get a raw file contents 148 # 149 # Parameters: 150 # id (required) - The ID or code name of a project 151 # sha (required) - The commit or branch name 152 # filepath (required) - The path to the file to display 153 # Example Request: 154 # GET /projects/:id/repository/commits/:sha/blob 155 get ":id/repository/commits/:sha/blob" do 156 ref = params[:sha] 148 # 149 # Parameters: 150 # id (required) - The ID or code name of a project 151 # sha (required) - The commit or branch name 152 # filepath (required) - The path to the file to display 153 # Example Request: 154 # GET /projects/:id/repository/commits/:sha/blob 155 get ":id/repository/commits/:sha/blob" do 156 ref = params[:sha] 157 158 commit = user_project.commit ref 159 error!('404 Commit Not Found', 404) unless commit 160 161 tree = Tree.new commit.tree, user_project, ref, params[:filepath] 162 error!('404 File Not Found', 404) unless tree.try(:tree) 163 105 115 end 116 117 describe "GET /projects/:id/:sha/blob" do 118 it "should get the raw file contents" do 119 get "#{api_prefix}/projects/#{project.code}/repository/commits/master/blob?filepath=README.md&private_token=#{user.private_token}" 120 121 response.status.should == 200 122 end 123 124 it "should return 404 for invalid branch_name" do 125 get "#{api_prefix}/projects/#{project.code}/repository/commits/invalid_branch_name/blob?filepath=README.md&private_token=#{user.private_token}" 126 127 response.status.should == 404 128 end 129 130 it "should return 404 for invalid file" do 33 33 present user_project.repo.heads.sort_by(&:name), :with => Entities::RepoObject 34 34 end 35 35 36 # Get a single branch 37 # 38 # Parameters: 39 # id (required) - The ID or code name of a project 40 # branch_id (required) - The name of the branch 131 143 @snippet = user_project.snippets.find(params[:snippet_id]) 132 144 present @snippet.content 133 145 end 146 147 # Get a raw file contents 148 # 149 # Parameters: 150 # id (required) - The ID or code name of a project 151 # sha (required) - The commit or branch name 152 # filepath (required) - The path to the file to display Created by: NARKOZ
@CodeAdept what version of ruby are you using? What error message do you get without rake 0.8.7? I'm sure this issue isn't related to Gitlab.
Run
bundle update grape
to update only grape.By Administrator on 2012-07-30T10:22:31 (imported from GitLab project)
By Administrator on 2012-07-30T10:22:31 (imported from GitLab)
Created by: punkisdead
I'm not sure what happened, but Rake 0.9.2 is working for me now. I didn't update any other dependencies except for that and Grape, all of the rest of the updates to the Gemfile.lock are probably because I'm building this on a fresh install and there are newer versions of all of the gems since you've been developing this project. All I did was run bundle install after checking out the project and those were the versions it gave me.
I've made the other changes as requested.
By Administrator on 2012-07-30T14:30:05 (imported from GitLab project)
By Administrator on 2012-07-30T14:30:05 (imported from GitLab)
33 33 present user_project.repo.heads.sort_by(&:name), :with => Entities::RepoObject 34 34 end 35 35 36 # Get a single branch 37 # 38 # Parameters: 39 # id (required) - The ID or code name of a project 40 # branch_id (required) - The name of the branch 41 # Example Request: 42 # GET /projects/:id/repository/branches/:branch_id 43 get ":id/repository/branches/:branch_id" do 44 @branch = user_project.repo.heads.find { |item| item.name == params[:branch_id] } 45 present @branch, :with => Entities::RepoObject Created by: NARKOZ
@punkisdead you forgot to update these lines
😄 By Administrator on 2012-07-31T14:34:19 (imported from GitLab project)
By Administrator on 2012-07-31T14:34:19 (imported from GitLab)
Created by: NARKOZ
bundle install
shouldn't changeGemfile.lock
. Can you revertGemfile.lock
changes and try to update only grape?Please don't forget to update
doc/api/projects.md
and squash your commits.By Administrator on 2012-07-30T17:44:46 (imported from GitLab project)
By Administrator on 2012-07-30T17:44:46 (imported from GitLab)
148 # 149 # Parameters: 150 # id (required) - The ID or code name of a project 151 # sha (required) - The commit or branch name 152 # filepath (required) - The path to the file to display 153 # Example Request: 154 # GET /projects/:id/repository/commits/:sha/blob 155 get ":id/repository/commits/:sha/blob" do 156 ref = params[:sha] 157 158 commit = user_project.commit ref 159 error!('404 Commit Not Found', 404) unless commit 160 161 tree = Tree.new commit.tree, user_project, ref, params[:filepath] 162 error!('404 File Not Found', 404) unless tree.try(:tree) 163 Created by: dzaporozhets
- revert Gemfile.lock except grape
- Squash commtis http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html
- Create a good commit description
- Apply @narkoz notes
By Administrator on 2012-07-31T13:21:27 (imported from GitLab project)
By Administrator on 2012-07-31T13:21:27 (imported from GitLab)
Created by: punkisdead
Ok, thanks for being patient guys. It's been a while since I've done any Rails development, and the first time "forking" and submitting a pull request on Github.
By Administrator on 2012-07-31T13:46:06 (imported from GitLab project)
By Administrator on 2012-07-31T13:46:06 (imported from GitLab)
Created by: dzaporozhets
@punkisdead hey congrats. Thank you for being patient also. Just tell us when you ready for final review :)
By Administrator on 2012-07-31T13:48:46 (imported from GitLab project)
By Administrator on 2012-07-31T13:48:46 (imported from GitLab)