Is it possible to get commits history for one file in gitlab api? - api

I want to get the commits or the last commit for one file in gitlab api like this:
GET /projects/:id/repository/commits?path=fileName
Gitlab support or not?

There is a patch that implements this feature:
https://gitlab.com/gitlab-org/gitlab-ce/issues/18898
Unfortunately, it has not been merged yet:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/4814
Edit: now merged, expected to land in 8.14.0 (2016-11-22): https://gitlab.com/gitlab-org/gitlab-ce/commit/146d4348ca6812e26729de40a831f4ae8c27fde6

Now you can do:
/projects/:id/repository/commits?path=:file_path
and receive array of commits about specific file.
Link to documentation

Unfortunately not. With GitLab 7.14 you can only get all commits of a repository with the following command:
GET /projects/:id/repository/commits

Related

GitLab api: how am i able the get the list of projects using gitlab api?

i was trying to get the list of projects in my gitlab using Git api. for that i was following Git lab api instruction.
they said i can access the list of project by this link:
https://gitlab.com/api/v4/projects?access_token=some_token.
but unfortunately with the above link i got bunch of information, which is not mine at all. i got the information which is owned by other users.
In that case how am i able the get my own projects information?
Nevertheless, the respond JSON has so many attribute. is there anyway that i can achieve the attribute according to my desire?
You can use owned=true to get only project which you are owner and simple=true to have limited field, check this :
https://gitlab.com/api/v4/projects?access_token=some_token&owned=true&simple=true

Getting file diff with Github API

net project for which I need to detect and parse changes made to a specific single text file in a repository between different pull requests.
I've been successfully able to access the pull requests and the commits using the Github API but I don't know how to retrieve the lines that changed in the last commit?
Is this possible using the API? What would be the best approach?
If not should I try to read the last two file versions and implement a differ algorithm locally?
Thanks!
A pull request contains a diff_url entry like
"diff_url": "https://github.com/octocat/Hello-World/pull/1347.diff"
You can do this for any commit. For example, to get the diff of commit 7fd1a60b01f91b3 on octocat's Hello-World it's https://github.com/octocat/Hello-World/commit/7fd1a60b01f91b314f59955a4e4d4e80d8edf11d.diff.
This also works for branches. Here's master on octocat's Hello-World. https://github.com/octocat/Hello-World/commit/master.diff.
The general form is:
https://github.com/<owner>/<repo>/commit/<commit>.diff
For private repositories:
curl -H "Accept: application/vnd.github.v3.diff" https://<personal access token>:x-oauth-basic#api.github.com/repos/<org>/<repo>/pulls/<pull request>
Also works with the normal cURL -u parameter.
See: https://docs.github.com/en/rest/reference/pulls#get-a-pull-request
The crux is in the requested media type. You can pass the Accept header with value
application/vnd.github.diff
see documentation. For full reference, a GET request with the above and Authorization header to https://api.github.com/repos/{orgName}/{repoName}/pulls/{prId} does the trick.

Bamboo Rest API multiple expands

Tried to fetch information for multiple builds from bamboo using the rest api. The information for the builds should include the ticket names the builds affacted and the commit messages for the commits which are included in these builds.
My Approch was the following:
{bambooUrl}/rest/api/latest/result/{projectkey}-{buildKey}.json?expand=results.result.vcsRevisions
{bambooUrl}/rest/api/latest/result/{projectkey}-{buildKey}.json?expand=results.result.jiraIssues
Both of these calls work fine but I need them merged together in one call:
I have tried the following:
{bambooUrl}/rest/api/latest/result/{projectkey}-{buildKey}.json?expand=results.result.jiraIssues,results.result.vcsRevisions
But this call just expands the vcsRevisions for me. Does someone have an tip for me how to use multiple expands?
I might be too late to answer your question, but solution might help others.
{bambooUrl}/rest/api/latest/result/{projectkey}-{buildKey}.json?expand=jiraIssues,vcsRevisions
worked for me

is there any gitlab API to rename a group

I am using GitLab 6.9.2 e46b644, I can not find any API to rename a group from API doc, but from gitlab UI, it really support rename group.
any idea if I need to batch rename groups?
Thanks in advance.
As you've said, it's not documented at: https://github.com/gitlabhq/gitlabhq/blob/4a5044e30269f8b3c6c075093cd4646a478231c7/doc/api/groups.md
Also, it's not implemented at: https://github.com/gitlabhq/gitlabhq/blob/4a5044e30269f8b3c6c075093cd4646a478231c7/lib/api/groups.rb which would be the obvious place.
And I could not find any feature request at http://feedback.gitlab.com
So I think it is safe to assume that it is not possible. I recommend that you open a feature request at http://feedback.gitlab.com

How can I retrieve a Gitlab Project tag list through the API?

I'm writing a REST client to look at project information available from several gitlab servers at the same time in one consolidated place. I understand REST and am able to pull the project details I need except one: the tags.
I'm not talking about git repository tags, those I'm able to get to just fine. I'm referring to the tags that are set under Project Settings. These are tags that, from what i can tell, are meant to be a form of describing the project, not referencing a particular commit hash.
I submitted a merge request back to the Gitlab folks, if accept, any REST call that involves a Project class will include a "tag_list" field with all the project labels.
The merge request is available here: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/329
EDIT: This was merged in Gitlab version 7.10.0 so now you can just run a GET on the Project and the tag_list will be included with the JSON response.
Try this:
http://www.example.com.br/api/v3/projects/#{str}/repository/tags?private_token=yourtoken"
Note that in #{str} variable, if you using a group/repository structure, you must replace the dash to %2F, for example, you must set:
http://www.example.com.br/api/v3/projects/group%2Frepository/repository/tags?private_token=yourtoken"
The response to your request will be the body. So you can console log response.body to retrieve the tags.
Not possible: ACCEPTING MERGE REQUEST at: http://feedback.gitlab.com/forums/176466-general/suggestions/6325819-project-labels-via-api , so feel free to implement it if you need it.
Should be simple: just return the project.tag_list (see: https://github.com/mbleigh/acts-as-taggable-on) as a JSON list from https://github.com/gitlabhq/gitlabhq/blob/41518a467dcef61deca24ad2f6205c6fd5706e1b/lib/api/projects.rb#L60
Always check the request tracker first for features ;) True, in this case you may have done it an not found because of label vs tag keyword confusion, I think it was renamed at some point, so always search for both.