Class: GitlabAwesomeRelease::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/gitlab_awesome_release/cli.rb

Constant Summary collapse

DEFAULT_VERSION_FORMAT =
"^v?[\\d.]+".freeze
DEFAULT_MERGE_REQUEST_COMMIT_FORMAT =
"^Merge branch .*See merge request .*\!(\d+)$".freeze
GITLAB_ENV_FILES =
%w[.env.gitlab ~/.env.gitlab].freeze
GITLAB_API_DESCRIPTION =
"GitLab API endpoint (e.g. http://example.com/api/v4)".freeze
GITLAB_API_PRIVATE_TOKEN_DESCRIPTION =
"Your private token".freeze
GITLAB_API_PROJECT_NAME =
"Target project (e.g. group/repo_name)".freeze
LOG_LEVEL_DESCRIPTION =
"Log level (debug|info|warn|error|fatal|unknown)".freeze

Instance Method Summary collapse

Instance Method Details

#create_latest_noteObject



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/gitlab_awesome_release/cli.rb', line 56

def create_latest_note
  Dotenv.load(*GITLAB_ENV_FILES)

  project = create_project

  tag_names = project.release_tag_names

  changelog =
    if tag_names.count >= 2
      project.generate_change_log(tag_names[-2], tag_names[-1])
    elsif tag_names.count == 1
      project.generate_change_log(tag_names[0], tag_names[0])
    end

  write_changelog(changelog) if changelog
  @logger.info "finish!"
end

#create_noteObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/gitlab_awesome_release/cli.rb', line 33

def create_note
  Dotenv.load(*GITLAB_ENV_FILES)

  project = create_project

  tag_names = project.release_tag_names
  oldest_tag = option_or_env(:from_tag) || tag_names.first
  newest_tag = option_or_env(:to_tag)   || tag_names.last

  changelog = project.generate_change_log(oldest_tag, newest_tag)

  write_changelog(changelog)
  @logger.info "finish!"
end

#markingObject



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/gitlab_awesome_release/cli.rb', line 82

def marking
  Dotenv.load(*GITLAB_ENV_FILES)

  from_tag  = option_or_env!(:from_tag)
  to_tag    = option_or_env!(:to_tag)
  label     = option_or_env(:label) || to_tag

  project = create_project

  project.merge_request_iids_between(from_tag, to_tag).each do |iid|
    mr = project.merge_request(iid)
    project.add_merge_request_label(mr, label) if mr
  end
  @logger.info "finish!"
end

#versionObject



19
20
21
# File 'lib/gitlab_awesome_release/cli.rb', line 19

def version
  puts GitlabAwesomeRelease::VERSION
end