mrooding / gitlab-semantic-versioning Goto Github PK
View Code? Open in Web Editor NEWDocker image that can be used to set up automatic semantic versioning using Gitlab merge request labels
License: Apache License 2.0
Docker image that can be used to set up automatic semantic versioning using Gitlab merge request labels
License: Apache License 2.0
Hi, While executing this code by using GitLab Got an error as line 5 in module import semver. ( no module named 'semver')
Hi!
I believe I found a way to extract the merge request labels directly from the merge commit.
The idea is that a merge commit always has two parent commits. The first one is the previous commit in the master branch, the second one the the previous commit in the feature branch
Using the python gitlab sdk:
def get_feature_merge_request(project, commit):
mr_iid = project.commits.get(commit.parent_ids[-1]).merge_requests()[0]["iid"]
return project.mergerequests.get(mr_iid)
Getting the project
and commit
object should be straightforward with the environment variables provided by the Gitlab CI.
import os
gl = gitlab.Gitlab('http://10.0.0.1', job_token=os.environ['CI_JOB_TOKEN'])
gl.auth()
project = gl.project.get(os.environ["CI_PROJECT_ID"])
commit = project.commits.get(os.environ["CI_COMMIT_SHA"])
Putting it all together:
>>> get_feature_merge_request(project, commit).labels
["bump-minor"]
I believe this has two advantages:
I think this look pretty promising - but maybe I'm missing something? ๐ค
What do you think? Does anything speak against this approach?
The regex in extract_merge_request_id_from_commit() function only captures the first digit of a merge request.
matches = re.search(r'(\S*\/\S*!)(\d)', message.decode("utf-8"), re.M|re.I)
Simply adding + to the (\d)
should do the trick as shown below:
matches = re.search(r'(\S*\/\S*!)(\d+)', message.decode("utf-8"), re.M|re.I)
How is this project licensed?
Hi, thanks for starting this project!
I would like to specify custom label names, e.g. "Removal" and "Feature" instead of "bump-major" and "bump-minor". I believe making this configurable through environment variables (with "bump-major" and "bump-minor" as defaults) would really help many people out.
I'd be glad to do a PR on this one. :)
Hi Marc,
Firts at all, thank you for this project.
Maybe will be better use a gitlab access token instead of user/password for security resasons.
Thank you
Best regards
If I have more than one tag on a commit git describe --tags
might return the wrong tag. What about adding an environment variable with tag names to be excluded? These names could be passed to git describe
with --exclude latest --exclude stable
What do you think?
is npa username are my gitlab username? thank you anyway
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.