0

I'm writing some automatic scripts using Bitbucket Server API. I have a lot of actions here, with pull request creation, etc.

For some reason I need to synchronize some branch with remote and merge with other branches(git merge).

Is it possible to do something like:

git checkout my_branch
git pull
git merge another_branch

I can do this staff via direct shell calls, but it requires branch cloning, etc.

Any ideas?

smart
  • 1,975
  • 5
  • 26
  • 46
  • [GitPython](https://pypi.python.org/pypi/GitPython/) library for example does abstract the git commands – Dan Ionescu Feb 25 '17 at 16:52
  • @DanIonescu, don't I need to clone my repository before using of this library? – smart Feb 25 '17 at 16:53
  • yes but the clonning can also be made from the python library and if you're worried about disk space you can delete it afterwards – Dan Ionescu Feb 25 '17 at 16:59
  • @DanIonescu, it's not so easy, because my repository is huge enough and it may be too long... – smart Feb 25 '17 at 17:03
  • Try bitbucket [API](https://developer.atlassian.com/static/rest/bitbucket-server/4.14.0/bitbucket-rest.html#idm45183781754144) they have a POST request in their REST API for merge operations – Dan Ionescu Feb 25 '17 at 17:09
  • @DanIonescu, where? I can see just for merging pull requestsm but I'm not sure if it's the same... – smart Feb 25 '17 at 17:10
  • You're right you it's not the same thing, you have to create a pull request first and then merge it.. – Dan Ionescu Feb 25 '17 at 17:16
  • @DanIonescu, I'm interesting first, in auto-merging(fast-forwarding), and then create pull request(if it's needed) – smart Feb 25 '17 at 17:18

1 Answers1

1

There is a new edit API (since 4.13) if you just want to edit a single file. Git itself is the API we'd recommend for manipulating Git repos otherwise.

Regarding repo sizes, you can do a shallow clone with modern versions of Git to pull down less data, and still push back. Depending on your scenario, you might also be able to maintain a local copy over time instead of cloning each time.

Rog
  • 4,075
  • 2
  • 24
  • 35