Stash API - How do you Fork to a user's account as Admin

As a System Admin, I'm trying to migrate many user's accounts which currently have forks of upstream repository, how would I go about doing that via the API.

I looked for a way to do it with the fork create request, and didn't see a way to masquerade as user option.

3 answers

This widget could not be displayed.

Hi Sean,

If you're talking about doing this in-process as a Java plugin you might be interested in the SecurityService. Is that what you had in mind?

Just out of curiosity what kind of migration are you doing exactly?

Cheers,

Charles

This widget could not be displayed.

I was hoping to do this using the Rest API, but this is exactly what I had in mind.

I'm looking to migrate a rather large userbase with quite a few Repos & quite a few Forks per Repo (from github) and I'd like to keep the structure intact. That means as far as I can tell, using the Forking creation api, you can only do it either to the user's default, or a project using a KEY.

My plan of attack was what I listed above, but if I have to go to the Java Plugin route, that would be okay whilst slower as I can write Java as well.

What do you think Charles, is there a better way to go about it?

Thanks,

Sean

Hi Sean,

Thanks for the details.

I think to create the forks themselves you're going to have to use a custom Java pluin just to create the forks. So my advice would be to import the parent repositories (either as a script/REST or Java), and then write a simple plugin that does the forking in Java. You could even just expose 'forkAsUser' as a REST endpoint and then control the rest from a script. Obviously make sure you turn that plugin off when you're done.

Let me know if you get stuck with the plugin. Also, if you can, please post any details/code on your migration as I'm sure others will find it useful. :)

Charles

This widget could not be displayed.

Cool, yea I'm going down that path, I think I have eclipse configured and the sdk installed correctly.

Was checking into the tutorials, to get a feel for coding a plugin.

You feel like sending some links that would relevant to building this project to give me a shove in the right direction?

Hi Sean,

I'm always a fan of examples over tutorials:

http://atlassian.bitbucket.org/#stash

There's obviously our dev docs as well:

https://developer.atlassian.com/stash/docs/latest/

Good luck. :)

Charles

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Aug 21, 2018 in Bitbucket

Branch Management with Bitbucket

As a project manager, I have discovered that different developers want to bring their previous branching method with them when they join the team. Some developers are used to performing individual wo...

1,310 views 8 11
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you