Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added rudimentary gitlab support #657

Open
wants to merge 29 commits into
base: master
Choose a base branch
from

Conversation

kreczko
Copy link

@kreczko kreczko commented May 30, 2018

This is my first attempt at adding Gitlab support to this very convenient project (fixes #419).
I took a copy of octo_fetcher and modified it to match the gitlab module.
It is pretty much rough around the edges and I am looking for feedback to nail down the last bits.
Tested on both public gitlab.com repo and a private instance (older gitlab version), the former is a bit slow.

While I can get a nice looking CHANGELOG from a test repo, the entries are not right (see below).

Outstanding issues:

  • the notation of PRs is different gitlab github (! vs #)
  • test issue number 2 in the example is not matched to the tag but the corresponding PR is. closed_at of issue and creation time for tag are pointing to the same minute.

Example changelog for public project

Unreleased

Full Changelog

Closed issues:

  • Test issue number 2 #2

v0.0.0 (2018-05-30)

Full Changelog

Closed issues:

  • Test issue number 1 #1

Merged pull requests:

* This Changelog was automatically generated by github_changelog_generator

@antenore
Copy link

antenore commented Jul 17, 2018

This is really cool!
If you need testing I can help out from time to time.
We have a quite interesting Changelog https://gitlab.com/Remmina/Remmina

Thanks!

@antenore
Copy link

antenore commented Jul 27, 2018

Hey @kreczko I'm having some big troubles to make it working, I've solved what was just a config problem on my side, and now I'm stuck with this:

/home/tmow/.rvm/gems/ruby-2.4.0/gems/gitlab-4.4.0/lib/gitlab/objectified_hash.rb:26:in `method_missing': wrong number of arguments (given 2, expected 1) (ArgumentError)
        from /home/tmow/.rvm/gems/ruby-2.4.0/gems/gitlab-4.4.0/lib/gitlab/error.rb:40:in `build_error_message'
        from /home/tmow/.rvm/gems/ruby-2.4.0/gems/gitlab-4.4.0/lib/gitlab/error.rb:16:in `initialize'
        from /home/tmow/.rvm/gems/ruby-2.4.0/gems/gitlab-4.4.0/lib/gitlab/request.rb:64:in `exception'
        from /home/tmow/.rvm/gems/ruby-2.4.0/gems/gitlab-4.4.0/lib/gitlab/request.rb:64:in `raise'
        from /home/tmow/.rvm/gems/ruby-2.4.0/gems/gitlab-4.4.0/lib/gitlab/request.rb:64:in `validate'
        from /home/tmow/.rvm/gems/ruby-2.4.0/gems/gitlab-4.4.0/lib/gitlab/request.rb:44:in `block (2 levels) in <class:Request>'
        from /home/tmow/.rvm/gems/ruby-2.4.0/gems/gitlab-4.4.0/lib/gitlab/client/projects.rb:37:in `project_search'
        from /home/tmow/.rvm/gems/ruby-2.4.0/gems/github_changelog_generator-1.15.0.pre.rc/lib/github_changelog_generator/gitlab_fetcher.rb:48:in `find_project_id'
        from /home/tmow/.rvm/gems/ruby-2.4.0/gems/github_changelog_generator-1.15.0.pre.rc/lib/github_changelog_generator/gitlab_fetcher.rb:43:in `initialize'
        from /home/tmow/.rvm/gems/ruby-2.4.0/gems/github_changelog_generator-1.15.0.pre.rc/lib/github_changelog_generator/generator/generator.rb:38:in `new'
        from /home/tmow/.rvm/gems/ruby-2.4.0/gems/github_changelog_generator-1.15.0.pre.rc/lib/github_changelog_generator/generator/generator.rb:38:in `initialize'
        from /home/tmow/remmina_devel/github-changelog-generator/lib/github_changelog_generator.rb:29:in `new'
        from /home/tmow/remmina_devel/github-changelog-generator/lib/github_changelog_generator.rb:29:in `initialize'
        from ../github-changelog-generator/bin/github_changelog_generator:5:in `new'
        from ../github-changelog-generator/bin/github_changelog_generator:5:in `<main>'

Any ideas what I'm still missing?

As API endpoint I've set this:

GITLAB_API_ENDPOINT="https://gitlab.com/api/v4/projects/7153509"

Is it correct?

@kreczko
Copy link
Author

kreczko commented Aug 7, 2018

@antenore The way I've been testing it:

github_changelog_generator --user ${GITLAB_USER} --project ${GITLAB_PROJECT} \
--github-site ${GITLAB_SITE} --github-api ${GITLAB_API} --verbose --gitlab

with

export CHANGELOG_GITHUB_TOKEN=<secret>
export GITLAB_SITE=https://gitlab.com
export GITLAB_API=https://gitlab.com/api/v4
export GITLAB_PROJECT=changelog-testrepo
export GITLAB_USER=kreczko

@skywinder
Copy link
Member

skywinder commented Sep 26, 2018

Yay, @kreczko that's a super cool and really "wanted" feature, as I can see from the likes! :)

And thanks, that you continue work on this branch.

I check the code - looks very neat. Even with small improvements of legacy code.

Let's add tests, at least of the basic things, based on your repo and I would be happy to support Gitlab! ❤️

@skywinder skywinder requested a review from olleolleolle Sep 26, 2018
@kreczko
Copy link
Author

kreczko commented Sep 27, 2018

Awesome, thanks @skywinder. I will try to add a set of tests in the coming weeks, time permitting.

Copy link
Collaborator

@olleolleolle olleolleolle left a comment

Hello!

I see all your effort - and it looks like a lot of work!

I made a ton of tiny comments, all of which are about naming and style, which make them easy to fix.

Oh, one thing which is always needed is man page (see its .md document) and README usage sections for the functional additions.

Do you currently use the code in this PR to generate changelogs?

Good job, keep it up!

lib/github_changelog_generator/gitlab_fetcher.rb Outdated Show resolved Hide resolved
lib/github_changelog_generator/gitlab_fetcher.rb Outdated Show resolved Hide resolved
lib/github_changelog_generator/gitlab_fetcher.rb Outdated Show resolved Hide resolved
lib/github_changelog_generator/gitlab_fetcher.rb Outdated Show resolved Hide resolved
lib/github_changelog_generator/gitlab_fetcher.rb Outdated Show resolved Hide resolved
lib/github_changelog_generator/gitlab_fetcher.rb Outdated Show resolved Hide resolved
lib/github_changelog_generator/gitlab_fetcher.rb Outdated Show resolved Hide resolved
@pagnmickie
Copy link

pagnmickie commented Oct 17, 2018

Following as I need this as well. 💯

cdenneen added a commit to cdenneen/pdk-templates that referenced this pull request Jan 29, 2020
 - Added github_site for remote server
 - Added github_endpoint for remote server
 - Added gitlab for preparation of gitlab support added in (github-changelog-generator/github-changelog-generator#657)

 These settings will not be added by default. Only if added to .sync.yml
 They allow for GitHub Enterprise and Gitlab options down the road.
@cdenneen
Copy link

cdenneen commented Jan 29, 2020

@kreczko Do you know if the labels are working properly?
I've tagged a few MR's (68 as maintenance, 65 as bugfix, 66 as enhancement) but still result in a CHANGELOG.md with the following when those should be excluded in case of maintenance, ### Fixed for bugfix and ### Added for enhancement:

Here is the config:

  GitHubChangelogGenerator::RakeTask.new :changelog do |config|
    raise "Set CHANGELOG_GITHUB_TOKEN environment variable eg 'export CHANGELOG_GITHUB_TOKEN=valid_token_here'" if Rake.application.top_level_tasks.include? "changelog" and ENV['CHANGELOG_GITHUB_TOKEN'].nil?
    config.github_site = 'https://gitlab.domain.tld'
    config.github_endpoint = 'https://gitlab.domain.tld/api/v4'
    config.gitlab = true
    config.user = "puppet"
    config.project = "puppet_profile_base"
    config.future_release = "v2.2.6"
    config.exclude_labels = ['maintenance']
    config.header = "# Change log\n\nAll notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org)."
    config.add_pr_wo_labels = true
    config.issues = false
    config.merge_prefix = "### UNCATEGORIZED PRS; GO LABEL THEM"
    config.configure_sections = {
      "Changed" => {
        "prefix" => "### Changed",
        "labels" => ["backwards-incompatible"],
      },
      "Added" => {
        "prefix" => "### Added",
        "labels" => ["feature", "enhancement"],
      },
      "Fixed" => {
        "prefix" => "### Fixed",
        "labels" => ["bugfix"],
      },
    }
  end
# Change log

All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org).

## [v2.2.6](https://gitlab.domain.tld/puppet/puppet-profile_base/tree/v2.2.6) (2020-01-27)

[Full Changelog](https://gitlab.domain.tld/puppet/puppet-profile_base/compare/v2.2.5...v2.2.6)

### UNCATEGORIZED PRS; GO LABEL THEM

- Release 2.2.6 [\#68](https://gitlab.domain.tld/puppet/puppet-profile_base/merge_requests/68) ([cdenneen](https://gitlab.domain.tld/cdenneen))

## [v2.2.5](https://gitlab.domain.tld/puppet/puppet-profile_base/tree/v2.2.5) (2020-01-27)

[Full Changelog](https://gitlab.domain.tld/puppet/puppet-profile_base/compare/v2.2.4...v2.2.5)

### UNCATEGORIZED PRS; GO LABEL THEM

- More updates to match upstream [\#67](https://gitlab.domain.tld/puppet/puppet-profile_base/merge_requests/67) ([cdenneen](https:/gitlab.domain.tld/cdenneen))

## [v2.2.4](https://gitlab.domain.tld/puppet/puppet-profile_base/tree/v2.2.4) (2020-01-27)

[Full Changelog](https://gitlab.domain.tld/puppet/puppet-profile_base/compare/v2.2.3...v2.2.4)

## [v2.2.3](https://gitlab.domain.tld/puppet/puppet-profile_base/tree/v2.2.3) (2020-01-24)

[Full Changelog](https://gitlab.domain.tld/puppet/puppet-profile_base/compare/v2.2.2...v2.2.3)

### UNCATEGORIZED PRS; GO LABEL THEM

- \#\#\# Added Yum Repo Updates to match defaults [\#66](https://gitlab.domain.tld/puppet/puppet-profile_base/merge_requests/66) ([cdenneen](https://gitlab.domain.tld/cdenneen))

## [v2.2.2](https://gitlab.domain.tld/puppet/puppet-profile_base/tree/v2.2.2) (2020-01-24)

[Full Changelog](https://gitlab.domain.tld/puppet/puppet-profile_base/compare/v2.2.1...v2.2.2)

### UNCATEGORIZED PRS; GO LABEL THEM

- \#\#\# Fixed Manifold changes [\#65](https://gitlab.domain.tld/puppet/puppet-profile_base/merge_requests/65) ([cdenneen](https://gitlab.domain.tld/cdenneen))

@kreczko
Copy link
Author

kreczko commented Jan 29, 2020

@cdenneen I don't think so, I've not tested them

* upstream/master: (60 commits)
  fix yml
  add funding file
  update readme
  Update the gem release procedure
  Add release instructions to CONTRIBUTING
  v1.15.0
  Update changelog before 1.15.0
  Fix Performance/Count in entry_spec
  CI: Use the shorter image names for less maint (github-changelog-generator#716)
  Fix Layout/SpaceAroundOperators in octo_fetcher
  Add newline at the end of the changelog
  Update changelog after 1.15.0
  Update CHANGELOG for 1.15.0
  Run rubocop in each build job
  Ignore vendor directory
  Fix a long standing Style/WordArray rubocop issue
  Fix warning about missing Performance/RegexpMatch copy
  Remove unneeded spaces in CONTRIBUTING
  add comment about TOC
  update TOC file
  ...
@cdenneen
Copy link

cdenneen commented Jan 29, 2020

@NathanUrwin I know you were working on labels. Was this working for you? I haven't been able to track down where the issue is just yet.

@NathanUrwin
Copy link

NathanUrwin commented Jan 30, 2020

Hey @cdenneen 👋

From my initial usage, no I don't believe labels are supported at this time. I don't think it should be a deal breaker though. Label support can be added once the work from @kreczko has been merged.

I'm going to get some work done on this MR this weekend. I'll make sure to keep everyone posted!

@cdenneen
Copy link

cdenneen commented Jan 30, 2020

@skywinder confirmed this is working besides the known items that can be added/improved later

@GlennM
Copy link

GlennM commented Feb 12, 2020

I'm going to get some work done on this MR this weekend. I'll make sure to keep everyone posted!

How's this going so far, did you manage to get started on it @NathanUrwin ?

@NathanUrwin
Copy link

NathanUrwin commented Feb 12, 2020

Hey @GlennM 👋

I appreciate you following up with me. I did get started on this, but nothing too substantial so it's all still local. I'll make sure to post my progress here soon. Thanks again!

@skywinder
Copy link
Member

skywinder commented Feb 22, 2020

Looks great. I want to double-check this code and then merge it.

In case if you don't want to wait:
I made separate repo to test GitLab things: https://github.com/github-changelog-generator/gitlab-changelog-generator

I can add you as owners there, @kreczko @NathanUrwin @cdenneen so we can even make a separate gem for GitLab for now.

p.s. hmm. looks that we have to rename this project after this merge 😉 ***-changelog-generator

@GlennM
Copy link

GlennM commented Mar 19, 2020

Looks great. I want to double-check this code and then merge it.

Hi @skywinder , have you been able to double-check it already? Thanks for your reply and stay healthy

@ferrarimarco ferrarimarco removed this from the 2.0.0 milestone Apr 12, 2020
@tlf30
Copy link

tlf30 commented Aug 23, 2020

Any status on this? I would love to start using this in gitlab.

@pagnmickie
Copy link

pagnmickie commented Aug 23, 2020

I asked the same thing almost a year ago! #657 (comment)

@GlennM
Copy link

GlennM commented Aug 24, 2020

Any status on this? I would love to start using this in gitlab.

Because of this taking so long and needing a changelog, I had to look for another solution for my project (and I found one). The output will not 100% match the output mentioned in this request, though it works for my case.

@NathanUrwin
Copy link

NathanUrwin commented Oct 7, 2020

Hey all, I hope everyone and their loved ones have been safe and healthy. Unfortunately, I have not been able to work on this since I posted last. I do have a working solution for myself though, if anyone is interested in checking it out: https://github.com/NathanUrwin/gitlab-changelog-generator

I've created a simple GitLab Release Generator CLI tool that uses the above generator. See https://github.com/NathanUrwin/gitlab-release-generator

$ pip install gitlab-release-generator
$ gitlab-release
Usage: gitlab-release [OPTIONS] COMMAND [ARGS]...

  Run gitlab-release.

Options:
  --changelog-filepath TEXT    Changelog filepath. Can be set by
                               'CHANGELOG_FILEPATH' environment variable.
                               [required]

  --gitlab-api-url TEXT        Gitlab api url. Can be set by 'GITLAB_API_URL'
                               environment variable.  [required]

  --gitlab-namespace TEXT      Gitlab namespace. Can be set by
                               'GITLAB_NAMESPACE' environment variable.
                               [required]

  --gitlab-private-token TEXT  Gitlab private token. Can be set by
                               'GITLAB_PRIVATE_TOKEN' environment variable.
                               [required]

  --gitlab-project TEXT        Gitlab project. Can be set by 'GITLAB_PROJECT'
                               environment variable.  [required]

  --gitlab-site-url TEXT       Gitlab site url. Can be set by
                               'GITLAB_SITE_URL' environment variable.
                               [required]

  --releases-filepath TEXT     Releases filepath. Can be set by
                               'RELEASES_FILEPATH' environment variable.
                               [required]

  -v, --verbose                Enable verbose output.
  --version                    Show the version and exit.
  --help                       Show this message and exit.

Commands:
  delete    Delete a GitLab release.
  generate  Generate GitLab release data.
  upload    Create a GitLab release.

@skywinder
Copy link
Member

skywinder commented Nov 29, 2020

Hey, @NathanUrwin that's awesome.
Thank you very much for the update.

I don't have the brain capacity and time to review this project, currently overloaded with other tasks.

Would you like to integrate this into this project's single-solid-working solution with all these features that you mention?
I would be happy to add you to this project as contributors.

@skycaptain
Copy link

skycaptain commented Dec 28, 2021

Any news or anything we could to to push things forward? This feature would be so great since there are barely any mature changelog/release note generators for Gitlab.

@pagnmickie
Copy link

pagnmickie commented Dec 28, 2021

Any news or anything we could to to push things forward? This feature would be so great since there are barely any mature changelog/release note generators for Gitlab.

I have completely given up on this project. It’s been more than two years. It’s sad. They should pass it off to someone else to maintain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Gitlab (and other github-like backends)