Git Product home page Git Product logo

gitlab_mr_release's Introduction

GitlabMrRelease

Release MergeRequest generator for GitLab

Gem Version Build Status Code Climate Coverage Status

This is inspired by the git-pr-release

Requirements

  • Ruby v2.1+
  • GitLab v8.17.0+
  • GitLab API v4+

Installation

$ gem install gitlab_mr_release

Usage

init

Copy setting files. And edit these files.

$ gitlab_mr_release init
      create  .env.gitlab
      create  gitlab_mr_release.md.erb

see lib/templates/

create

$ gitlab_mr_release create --source=develop --target=master --labels=release
MergeRequest is created

[Title] Release develop -> master

[Description]
# MergeRequests

* [ ] !7 Add fresh @sue445

[Url] http://example.com/your/project/merge_requests/15

description is accepted MergeRequests title between --source and --target

merge_request

detail

$ gitlab_mr_release help create
Usage:
  gitlab_mr_release create

Options:
  -s, [--source=SOURCE]  # Source branch (e.g. develop)
  -t, [--target=TARGET]  # Target branch (e.g. master)
      [--title=TITLE]    # MergeRequest title (default. 'Release :timestamp :source -> :target')
  -l, [--labels=LABELS]  # Labels for MR as a comma-separated list  (e.g. 'label1,label2')

Create merge requrst

options

Some options can be specified in both the command arguments and environment variables

  • --source , DEFAULT_SOURCE_BRANCH (either one is required)
    • Source branch (e.g. develop)
  • --target , DEFAULT_TARGET_BRANCH (either one is required)
    • Target branch (e.g. master)
  • --title
    • MergeRequest title (default. 'Release :timestamp :source -> :target')
  • --labels , DEFAULT_LABELS
    • Labels for MR as a comma-separated list (e.g. label1,label2, default. no labels)

ProTip

.env.gitlab

Environment variables read from ~/.env.gitlab and current .env.gitlab

~/.env.gitlab

GITLAB_API_ENDPOINT=http://example.com/api/v4
GITLAB_API_PRIVATE_TOKEN=XXXXXXXXXXXXXXXXXXX
TEMPLATE_FILE=gitlab_mr_release.md.erb
DEFAULT_TITLE=Release <%= Time.now %> <%= source_branch %> -> <%= target_branch %>

current .env.gitlab

GITLAB_PROJECT_NAME=group/name
TEMPLATE_FILE=gitlab_mr_release.md.erb
DEFAULT_SOURCE_BRANCH=develop
DEFAULT_TARGET_BRANCH=master
DEFAULT_LABELS=release

If defined both ~/.env.gitlab and current .env.gitlab, current .env.gitlab is priority

variables in template

# MergeRequests
<% merge_requests.each do |mr| -%>
* [ ] !<%= mr.iid %> <%= mr.title %> @<%= mr.author.username %>
<% end -%>

merge_requests is array of MergeRequest

variables in DEFAULT_TITLE

DEFAULT_TITLE=Release <%= Time.now %> <%= source_branch %> -> <%= target_branch %>

DEFAULT_TITLE supports erb.

  • source_branch is --source or DEFAULT_SOURCE_BRANCH
  • target_branch is --target in DEFAULT_TARGET_BRANCH

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment. Run bundle exec gitlab_mr_release to use the gem in this directory, ignoring other installed copies of this gem.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/sue445/gitlab_mr_release.

License

The gem is available as open source under the terms of the MIT License.

gitlab_mr_release's People

Contributors

dependabot[bot] avatar paulownia avatar sue445 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

paulownia

gitlab_mr_release's Issues

I get an error when I enter the project name in GITLAB_PROJECT_NAME

It may have been used incorrectly, but it didn't work so please let me know.

When I create .env.gitlab and execute the command, the following error is output. However, if I enter the project ID instead of the project name in GITLAB_PROJECT_NAME, I get the expected result.

.env.gitlab

GITLAB_API_ENDPOINT=https://gitlab.com/api/v4/
GITLAB_API_PRIVATE_TOKEN=XXXXXXXXXXX
GITLAB_PROJECT_NAME=gitlab-org/gitlab-foss
TEMPLATE_FILE=gitlab_mr_release.md.erb
DEFAULT_TITLE=Release <%= Time.now %> <%= source_branch %> -> <%= target_branch %>
DEFAULT_SOURCE_BRANCH=master
DEFAULT_TARGET_BRANCH=develop
#DEFAULT_LABELS=release

result of 'gitlab_mr_release create'

Traceback (most recent call last):
        13: from /usr/local/bin/gitlab_mr_release:23:in `<main>'
        12: from /usr/local/bin/gitlab_mr_release:23:in `load'
        11: from /var/lib/gems/2.7.0/gems/gitlab_mr_release-1.1.1/exe/gitlab_mr_release:4:in `<top (required)>'
        10: from /var/lib/gems/2.7.0/gems/thor-1.1.0/lib/thor/base.rb:485:in `start'
         9: from /var/lib/gems/2.7.0/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch'
         8: from /var/lib/gems/2.7.0/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command'
         7: from /var/lib/gems/2.7.0/gems/thor-1.1.0/lib/thor/command.rb:27:in `run'
         6: from /var/lib/gems/2.7.0/gems/gitlab_mr_release-1.1.1/lib/gitlab_mr_release/cli.rb:55:in `create'
         5: from /var/lib/gems/2.7.0/gems/gitlab_mr_release-1.1.1/lib/gitlab_mr_release/project.rb:44:in `create_merge_request'
         4: from /var/lib/gems/2.7.0/gems/gitlab_mr_release-1.1.1/lib/gitlab_mr_release/project.rb:31:in `merge_request_iids_between'
         3: from /var/lib/gems/2.7.0/gems/gitlab-4.17.0/lib/gitlab.rb:28:in `method_missing'
         2: from /var/lib/gems/2.7.0/gems/gitlab-4.17.0/lib/gitlab/client/repositories.rb:59:in `compare'
         1: from /var/lib/gems/2.7.0/gems/gitlab-4.17.0/lib/gitlab/request.rb:51:in `block (2 levels) in <class:Request>'
/var/lib/gems/2.7.0/gems/gitlab-4.17.0/lib/gitlab/request.rb:59:in `validate': Server responded with code 404, message: 404 Ref Not Found. Request URI: https://gitlab.com:443https://gitlab.com/api/v4/projects/gitlab-org%2Fgitlab-foss/repository/compare?from=develop&to=master (Gitlab::Error::NotFound)

System configuration

  • ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux-gnu]
  • gitlab (4.17.0)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.