Grab files changed by commit from GitLab API - gitlab-api

I am trying to use the GitLab API to grab all files changed by a particular commit, but I don't see a good way of doing it.
In other words, whats the equivalent of git show --name-only sha1 in the GitLab API?

The only way I know of is using the following API Call.
GET /projects/:id/repository/commits/:sha/diff
(See: https://docs.gitlab.com/ee/api/commits.html#get-the-diff-of-a-commit)
If you only need the changed files, you could of course only look at the file Paths (old_path, new_path) in the Response

Related

Link to latest master build

I have a product for which I store software builds in Artifactory.
I name the software artifacts like this, so it is possible to se what a downloaded file contains: system-pcm33-base-v0.0.0.0_65_ga03970a.raucb
Thus it is also possible to download directly via an URL, not using jfrog
https://artifactory.deif.com/ui/native/amc-sw/pcm33/master/system-pcm33-base-v0.0.0.0_65_ga03970a.raucb
Now I would like to make a quick way to download the latest master build. To do this I have in my build made a symlink
system-pcm33-base.raucb -> system-pcm33-base-v0.0.0.0_65_ga03970a.raucb
I can also push this symlink to artifactory, but it only works from the GUI and via jfrog. I do not get this symlink as I had hoped:
https://artifactory.deif.com/ui/native/amc-sw/pcm33/master/system-pcm33-base.raucb
Is there a way to do this?
It is of course possible to upload the file twice under two different names, and thus update system-pcm33-base.raucb on every build. But that is a bit more heavy.
Artifactory doesn't handle symbolic links as in the Linux file system.
Based on the described use case, you can upload the file twice (as suggested) - first with the actual version, second as the latest. The important part is - when you upload for the 2nd time, as the latest, use Checksum Deploy.
Artifactory has a checksum based storage, which means that every file is actually stored once, even if it is uploaded to different target paths. In order to tell Artifactory to create/update a path without actually sending the binary, you can send the checksum of the binary, and Artifactory will link the path to the binary with that checksum. This operation is quite cheap.
Another possible approach is to define and use a custom Repository Layout. This way, in order to download the latest version of the file, you can use the [RELEASE] placeholder. The actual latest version ill be automatically resolved by the extracted version value based on the layout.
See also:
How to create simple versioning custom layout in Artifactory
How to find the latest artifact version based on layout?
Thanks to yinon explaining that the checksum is used, I found this simple solution
jf rt copy --flat amc-sw/pcm33/master/system-pcm33-base-v0.0.0.0_65_ga03970a.raucb amc-sw/pcm33/master/system-pcm33-base.raucb
This copies ALL the properties, but then a download query will return two files, so a property has to be changed
jf rt sp amc-sw/pcm33/master/system-pcm33-base.raucb artifact=last_bsp

How to get pull request by id using JGit

I've started using JGit for achieving git api calls through java based jGit lib.
I'm looking to get stats around what has changed in pullRequest in files for that I'll need to get details of pullRequest.
I'm facing challenges in finding approach in getting pull request by ID using JGit.
There is no clear and concise documentation, the cook-book also don't cover this portion.
PullRequests are not part of core Git, so JGit also does not have support.
So it depends on which Git server you are accessing, GitHub has support via special branches, e.g.
git fetch origin pull/ID/head:BRANCHNAME
e.g.
git fetch origin pull/223/head:local_test_branch
A similar fetch-command via JGit should work as well.
See https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/checking-out-pull-requests-locally for details

Configure Fluent-bit file output plugin set file rollover

I've a Fluent-bit running as docker instance which uses tail input plugin to read docker log files and currently I've configured output plugin to use Elasticsearch.
However in prod since Elasticsearch resides on another zone, don't want to consume bandwidth I don't want to use Elasticsearch, instead want to use file output plugin. But in file plugin there is no documentation explaining the file rollover configuration.
At the moment there is no such feature in Fluent Bit File output plugin. Please log the enhancement request on GitHub:
https://github.com/fluent/fluent-bit/issues/new?template=feature_request.md
Since this feature makes a lot of sense it can be implemented shortly,
regards,
Eduardo
Fluent Bit Maintainer

BitBucket Server API Call For Deleting and/or Renaming Content

Looking here for an API endpoint to delete and/or rename a piece of content in a repository. I don't see anything relevant. How does one do this?
https://developer.atlassian.com/bitbucket/api/2/reference/
Unfortunately, in May 2017 Atlassian stated that it is not supported.
When looking at the Bitbucket REST API of version 5.10.1 in June 2018, it is still not supported.
There is a files endpoint at /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/files, but it only has a GET endpoint to list the files in a specific directory of the repository.
There also is a /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/browse/{path:.*} endpoint. It supports GET to list the files in a directory of a repository and supports PUT to commit one file per call. However, DELETE is not supported on that endpoint.
The same goes for renames. The documentation does not mention the ability to do so with a REST API call.
/2.0/repositories/{username}/{repo_slug}/src This API can be used to update or delete files.
From docs
To create a commit that deletes files, use the files parameter:
$ curl https://api.bitbucket.org/2.0/repositories/username/slug/src \
-F files=/file/to/delete/1.txt \ -F files=/file/to/delete/2.txt
You can add/modify/delete multiple files in a request. Rename/move a
file by deleting the old path and adding the content at the new path.

How can I fetch the build versions from Artifactory repository

I have to fetch the list of builds present here : https://openmrs.jfrog.io/openmrs/public/org/openmrs/api/openmrs-api/
I am new to artifactory and its api. I need to know the curl command for fetching all the version numbers mentioned there please? How do I go about it? It's worthwhile to know that the repo doesn't belong to me and hence I do not have the username and password for it(Incase that's needed).
In the artifactory rest API documentation they use localhost for this purpose and do not have such a link. I haven't set this repo up so I do not know how it's done. Basically I am new to this and hence any help would be appreciated.
Thanks
Assuming you would like to get the list of versions available in this folder, there are 2 possible options:
1) Use the folder info REST API method to get a list of all the sub-folders
curl https://openmrs.jfrog.io/openmrs/api/storage/public/org/openmrs/api/openmrs-api/
2) Download and parse the maven-metadata.xml file inside this folder. This file contains information about available versions.

Resources