Rename BitBucket repository using REST API 2.0? - rest

The only other chatter I've found about a rename-repo operation is based on the 1.0 REST API, which stopped working a year or so ago.
I should be able to use this documentation, but so far no luck: I find the "request example" confusing.
The "Note:" clearly implies that it should be possible to rename a repository using the 2.0 API. ("Note: Changing the name of the repository will cause the location to be changed.")
But a PUT to 2.0/repositories/owner/repo with data {"full_name": "owner/newname"} doesn't seem to change the name. Evidently it does locate the right repository, because I get back JSON describing that repository, but still with the original name. The web UI finds the original name, does not find the new name.
I would just like a working example of the data body to PUT to the 2.0/repositories/owner/repo path to rename owner/repo. Thanks.
(n.b. I already know how to rename a repo using the web UI. I must rename 84 repositories and would rather not do it by hand.)

It appears that {"name": "newname"} works. Attempting to change "full_name" or "slug" does not. TIL...

Related

GitHub Releases Download URL Redirect Doesn't Seem to Work

I've checked out this here on Stack Overflow, but following what's outlined there, I'm still getting "not found" on pages that I know have releases.
For example, if I want to download the latest URL for something like https://github.com/storybookjs/storybook/releases, for a number of repositories dynamically, why do I get a 404 when I use https://github.com/storybookjs/storybook/releases/latest/download/package.zip
What am I missing here?
Thanks in advance!
It might be easier to use GitHub's API for that, as documented for releases. The URL format is
https://api.github.com/repos/{owner}/{repo}/releases
For example, https://api.github.com/repos/symfony/symfony/releases lists all releases for a PHP package. The JSON node zipball_url contains a link to a ZIP package for each release.

AzureDevOps API CodeSearch is returning old file (that has been renamed)

I have a service that request all our repositories then for each repository, i'm getting all the csproj and vbproj in the repository.
My problem is that it return 2 versions of the same file!
Ex:
A project has been created that way => MYPROJECT.csproj and commited,
then renamed to MyProject.csproj and commited.
But the CodeSearch Api is returning both file!
How can i know which one is the right one ?
Documentation doesn't seems to mention it or I'm not understanding which properties I need to send or which properties is telling me that it's an old file.
Documentation
https://learn.microsoft.com/en-us/rest/api/azure/devops/search/code%20search%20results/fetch%20code%20search%20results?view=azure-devops-rest-5.1
URL
https://almsearch.dev.azure.com/MyOrganisation/MyProject/_apis/search/codesearchresults?api-version=5.1-preview.1
BODY
{
'searchText': 'ext:csproj',
'includeFacets': false,
'$skip': 0,
'$top': 1000,
'filters': {
'Project': ['MyProject']
},
'$orderBy': [{
'field': 'filename',
'sortOrder': 'ASC'
}]
}
When I do the same research directly on DevOps, I see this flag over the old file
So there must be a way to tell if it's an old file!
How can I get it ?
I could reproduce this issue on my side. In Tfvc Repo, the code search result will return all versions of the file.
Based on my test, the difference between them is versions -> changeid.
Generally changeid is incremental, so you could judge the old and new versions according to the value of changeid. This is a workaround.
On the other hand, I will help you to report this issue on our Developer Community forum, and after confirmation by our engineer, this issue will be reported to the product team. The product team would provide the updates if they view it.
I got the same message (I renamed file using git mv command):
I got this message after committing renamed file and when I clicked on search button. However, when I refreshed page, warning goes away:
For me it looks like search on web based on some kind of locally cached indexes, but it is aware that some file was changed. Thus you won't be able to achieve this via REST API call.

Get number of github downloads

I'm trying to figure out how to use the Github API to get the number of downloads of a release. I have a test repo called polymer-reptation under my username benlindsay with one tag, 1.0. A Github Developer page here says that to get the information on a single release I can use the command GET /repos/:owner/:repo/releases/:id. I can't figure out how to use that command though. I tried things like curl --user "benlindsay" https://api.github.com/repos/:benlindsay/:polymer-reptation/releases/:1.0 on the command line, the same thing without the colons, and typing similar things into hurl.it. They all just give me
{
"message": "Not Found",
"documentation_url": "https://developer.github.com/v3"
}
at best. Can someone show me to how to use this feature of the API? (an easier way to track downloads would be helpful as well if one exists)
You should use it without the colons, they are there to indicate stuff you should replace.
However, Listing all releases at https://api.github.com/repos/benlindsay/polymer-reptation/releases Returns an empty array... No releases My guess is the API hasn't caught up yet. If this doesn't resolve itself shortly, contact GitHub.

unable to find DLFileEntryLocalServiceUtil.getFileEntryByTitle() in liferay 6.1

Is there any direct api to fetch a file entry by title with given folder id.
I have tried DynamicQueryFactoryUtil, apart from this is there anything to fetch DLFileEntries by title.
I believe DLFileEntryLocalServiceUtil.getFileEntryByTitle() is not there anymore in Liferay 6.1
In Liferay 6.1.0, I can see there is
com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil.getFileEntryByName(groupId, folderId, name), as I get from lib/ext/portal-service.jar
You can also see the official documentation here
I think you start by making sure you have the correct libraries imported
EDIT:
I guess that the parent folder and groupID are needed as more than 2 DLFileEntries can have the same title/name. If you need exactly 1 result, and giving only 1 attribute, you can use getDLFileEntry(long fileEntryId). If this doesn't help either, you should tell us some more on what you want to do , and what information you have available (except the title of course)
Liferay has a strange compatibility policy.
Seems like they renamed the getFileEntry to getFileEntryByName and getFileEntryByTitle to getFileEntry. The old and new getFileEntry both share the same singature, but the parameter name is different. :-(

Enforcing policies from Atlassian Stash Repository merge request check plugin

I need help on how to successfully create a RepositoryMergeRequestCheck
As part of our merge workflow, we need to ensure some policies about some files. Policies includes among others:
File naming conventions of individual files
File naming conventions between multiple files (for example, correlative-named files)
Inspection of files to enforce or disallow usage of statements or functions
I want to be able to check for this policies on a repository merge request check so I’m building a plugin for Astlassian Stash
I have tried the following approaches:
Using the RepositoryMergeRequestCheckContext parameter of RepositoryMergeRequestCheck.check()
Since the method signature is:
#Override
public void check(RepositoryMergeRequestCheckContext context)
The first thing I tried using was the context parameter. I can say context.getMergeRequest().getPullRequest().getFromRef().getRepository()
Now I get a Repository instance and I’m not sure how to extract commit info from it.
Calling Git directly: Since this check was originally developed as a git hook script, calling git from the SDK made sense to me. It led me to this situation:
String result = gitScm.getCommandBuilderFactory().builder().lsTree().build(…).call();
Where gitScm gets dependency injected in the plugin’s constructor.
Notice the build parameter? It expects a CommandOutputHandler<T> in this case T is string, but that’s an interface, and I’m not sure how to get an instance that implements that interface or how to create one.
REST API
REST API looks the easiest of them but it still doesn’t help with the third requirement of inspecting file’s source code and also, spawning web requests from the merge request check that is itself a web request from stash doesn’t seem to be a good idea from the performance side.
What path should I follow or how can I do it?
I started writing you a response, and then realised that I'd already answered this on Answers (which was what I was going to suggest as well).
https://answers.atlassian.com/questions/182943/enforcing-policies-from-repository-merge-request-check-plugin
Cheers,
Charles