This seems very useful. Would it work with gitlab instead of github? If not, any plans to support that?
Unfortunately it only supports the GitHub API for now.
You can see the GitHub API commands that are used here: https://github.com/singapore/renovate/blob/master/lib/api/github.js
Most are "generic" (create branch, get file contents, etc) but a few are quite GitHub-specific. It would probably be easily ported to support Gitlab if Gitlab API supports equivalent capabilities.
I'll rename this issue to "Gitlab support" and keep it open.
I myself moved all my projects to GitLab, for various reasons, and though that was a good decision in my case, I greatly miss the benefits of leveraging tools like GreenKeeper, and now renovate.
I went through the GitHub API file you have and looked for GitLab equivalents. As you noted, there are GitLab equivalents for most end-points (The URL and response body may be a little different.).
There are two shortcomings with the GitLab API. GitLab does not have a convenient search end-point, so all files and merge requests would need to be fetched, with filtering done on client side.
Lastly, there is no equivalent to the end-points used by the commitFile function (and the functions it uses), but there is a GitLab end-point to create commits with arbitrary files.
Each function is listed below, with the first API end-point being what's used in the GitHub file, and the second being what GitLab supports.
initRepo
getBranchCommit
getCommitTree
getRateLimit
findFilePaths
branchExists
createBranch
deleteBranch
updateBranch
getBranchPr
+
state=open&base=${config.defaultBranch}&head=${config.owner}:${branchName}addAssignee
addLabels
findPr
checkForClosedPr
createPr
getPr
branchName, which is not already passed to this function.getFile/getFileContent/getFileJson
writeFile
commitFile -> createBlob -> createTree -> createCommit
@hbetts that's awesome help - thanks.
I think that the two main shortcomings you mention are not blockers. In fact they are both essentially convenience functions.
For the "find file" one, that's used for convenience with monorepos to automatically discover all package.json files in a repo. It can be overridden if you manually configure all file locations instead. So in an initial release we could leave this off.
For "commit file", that is a low-level hack I recently added that enables two things:
Hence, I think that it's possible to get by without this low-level, and just deal with the implications.
I'm taking first steps to implement this
Getting there..

So.. Gitlab deleted themselves so work cannot resume yet.
They are transparent on the incident : https://docs.google.com/document/d/1GCK53YDcBWQveod9kfzW-VCxIABGiryG7_z_6jHdVik/pub
@rarkins wanted to say thank you for gl-got.
I've begun refactoring semantic-release-gitlab to take advantage of gl-got - https://gitlab.com/hyper-expanse/semantic-release-gitlab-notifier/merge_requests/3/diffs
Please let me know if there's anything I can do to help you with gl-got.
@hbetts I'm glad to hear it's of use! I thought it would make the GitLab API for renovate easier to keep consistent. I've added you as a Collaborator for gl-got in case you find anything missing. Let's bump it to 1.0.0 once we've tested it a bit and using it in production for either renovate or semantic-release-gitlab.
@hbetts after discussing with the gh-got author, I pushed some changes to GitHub
gh-gotgh-got latestHence this branch now uses gl-got version 6.0.0-rc0 and will update to 6.0.0 once I feel it's been validated enough. Feel free to let me know if you think it's ready.
GitLab support is now added in PR #83 and is ready for testing. Cc @guumaster @hbetts
As I'm not a regular GitLab user, I won't merge this PR until someone else thinks it's ready. Also feel free to comment on any of the implementation details.
Check the contributing.md for instructions on how to run locally (you'll also need to check out the relevant branch).
FYI here is how I am running it locally to test:
LOG_LEVEL=debug npm run start-babel -- --platform=gitlab <username/repo>
Thanks for all the effort guys! Great job. I'll try it asap and let you know
I ran renovate with the following command:
LOG_LEVEL=debug npm run start-babel -- --platform=gitlab --token=TOKEN --commitMessage="chore(package): update dependency {{depName}} to version {{newVersion}}" --labels=refactor,operations --onboarding=false hyper-expanse/test-project
Here's a section of the verbose output for the outdated semver dependency.
I'm including it here because the output ends with an _error_. That error appears for every single dependency that is updated. It should, however, be noted that merge requests do get created as expected - https://gitlab.com/hyper-expanse/test-project/merge_requests
debug: semver: Checking for closed PR
debug: findPr(renovate/semver-5.x, Pin dependency semver to version 5.3.0, closed)
debug: Closed PR existed: false
debug: Checking if branch exists: renovate/semver-5.x
debug: Branch doesn't exist
verbose: semver: creating new branch renovate/semver-5.x
debug: setNewValue: dependencies.semver = 5.3.0
debug: Starting search at index 544
debug: Found match at index 957
debug: Replacing "^5.1.0" with "5.3.0" at index 957
debug: commitFileToBranch(renovate/semver-5.x, package.json, fileContents, message, master)
debug: Checking if branch exists: renovate/semver-5.x
debug: Branch doesn't exist
debug: Creating branch renovate/semver-5.x
debug: package.json exists - updating it
debug: Ensuring PR
debug: getBranchPr(renovate/semver-5.x)
debug: Got res with 4 results
debug: Didn't find existing PR for branch renovate/semver-5.x
debug: Creating Merge Request: Pin dependency semver to version 5.3.0
debug: Adding labels refactor,operations to #2217526
error: semver failed to ensure PR: {"message":"Response code 404 (Not Found)","host":"gitlab.com","hostname":"gitlab.com","method":"PUT","path":"/api/v3/projects/hyper-expanse%2Ftest-project/merge_requests/prNo?labels=refactor,operations","statusCode":404,"statusMessage":"Not Found"}
So in addition to not understanding what the error is from, I also see two instances of Creating branch renovate/semver-5.x.
This may be out of the scope of this particular change, but upon figuring out what was causing the label error to occur, I re-ran renovate, mostly in hopes that it would go back and update all the pending pull requests with the two labels I specified.
Apparently if a pull request already exists, it only checks whether the body or title our out of date, and updates them if they are.
Would it make sense to update labels as well?
I didn't think it does. For example I add the label "ready" with renovate but remove it manually and replace with "waiting" if I need to add more code or perform manual tests. So I wouldn't want that ready label being added back again. Same logic for assignees.
@rarkins, that description of how you would interact with the pull requests makes sense, and I agree that automatically updating labels would be problematic. I retract my suggestion.
On the same topic, GitHub will automatically create labels you specify to add. Ie no such thing as a "label doesn't exist" error. Is GitLab the same?
gl-got 6.0.0-rc0 is now used by the latest version of semantic-release-gitlab-notifier, which has been released in version 3.0.0 of semantic-release-gitlab.
@hbetts In that case, I've pushed stable version 6.0.0 to npm
Apparently GitLab will create a label if it doesn't already exist:

Using --labels=doesntexist hyper-expanse/test-project
Most helpful comment
Unfortunately it only supports the GitHub API for now.
You can see the GitHub API commands that are used here: https://github.com/singapore/renovate/blob/master/lib/api/github.js
Most are "generic" (create branch, get file contents, etc) but a few are quite GitHub-specific. It would probably be easily ported to support Gitlab if Gitlab API supports equivalent capabilities.
I'll rename this issue to "Gitlab support" and keep it open.