Skip to content
Snippets Groups Projects

Api blob contents

Merged gitlab-qa-bot requested to merge github/fork/CodeAdept/api_blob_contents into master

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

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Created by: NARKOZ

    Thanks. I'll give it a closer look after this weekend.

    Please rebase it against master. Why Gemfile is changed?

    By Administrator on 2012-07-27T21:30:27 (imported from GitLab project)

    By Administrator on 2012-07-27T21:30:27 (imported from GitLab)

  • 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: punkisdead

    I've pulled the changes from upstream and rebased this branch against master.

    By Administrator on 2012-07-28T03:16:03 (imported from GitLab project)

    By Administrator on 2012-07-28T03:16:03 (imported from GitLab)

  • Created by: dzaporozhets

    @punkisdead Thank you for PR. @narkoz will review it but I have 2 problems with:

    1. Gemfile.lock has a lot of changes. We should not make gem updates & feature in one PR. Please rollback gems updates.
    2. 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)

  • gitlab-qa-bot
Unable to load the diff
  • Created by: NARKOZ

    whitespace

    By Administrator on 2012-07-31T14:34:19 (imported from GitLab project)

    By Administrator on 2012-07-31T14:34:19 (imported from GitLab)

  • gitlab-qa-bot
  • 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

      Use user_project helper

      By Administrator on 2012-07-31T14:34:19 (imported from GitLab project)

      By Administrator on 2012-07-31T14:34:19 (imported from GitLab)

  • gitlab-qa-bot
  • 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]
    • Created by: NARKOZ

      Can we change it to /projects/:id/repository/commits/:sha/blob?

      By Administrator on 2012-07-31T14:34:19 (imported from GitLab project)

      By Administrator on 2012-07-31T14:34:19 (imported from GitLab)

  • gitlab-qa-bot
  • 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: NARKOZ

      commit = user_project.commit ref

      By Administrator on 2012-07-31T14:34:19 (imported from GitLab project)

      By Administrator on 2012-07-31T14:34:19 (imported from GitLab)

  • gitlab-qa-bot
  • 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
    • Created by: NARKOZ

      Remove duplicate test

      By Administrator on 2012-07-31T14:34:19 (imported from GitLab project)

      By Administrator on 2012-07-31T14:34:19 (imported from GitLab)

  • gitlab-qa-bot
  • 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
    • Created by: NARKOZ

      The ID or code name of a project

      By Administrator on 2012-07-31T14:34:19 (imported from GitLab project)

      By Administrator on 2012-07-31T14:34:19 (imported from GitLab)

  • gitlab-qa-bot
  • 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

      ditto

      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

    @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)

  • gitlab-qa-bot
  • 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 change Gemfile.lock. Can you revert Gemfile.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)

  • gitlab-qa-bot
  • 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: NARKOZ

      unless tree.try(:tree)

      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: punkisdead

    What do you mean by squash my commits?

    By Administrator on 2012-07-31T13:19:10 (imported from GitLab project)

    By Administrator on 2012-07-31T13:19:10 (imported from GitLab)

  • Created by: dzaporozhets

    1. revert Gemfile.lock except grape
    2. Squash commtis http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html
    3. Create a good commit description
    4. 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)

  • Created by: punkisdead

    Ok, commits should be squashed now and docs updated.

    By Administrator on 2012-07-31T14:09:30 (imported from GitLab project)

    By Administrator on 2012-07-31T14:09:30 (imported from GitLab)

  • Created by: NARKOZ

    Nice. Merged.

    By Administrator on 2012-08-01T06:38:27 (imported from GitLab project)

    By Administrator on 2012-08-01T06:38:27 (imported from GitLab)

  • Please register or sign in to reply
    Loading