GitLab API | gitlab gem で 任意のプロジェクトの全ての Issue を疑似削除する
概要
gitlab gem で 任意のプロジェクトの全ての Issue を疑似削除します。
GitLabの Issue は物理削除も論理削除もありません。
そのため疑似的な削除方法として、
- タイトル : delete
- ステータス : close
- ラベル : deleted
に設定してみます。
サンプル
require 'gitlab'
Gitlab.configure do |config|
config.endpoint = 'http://some_path/api/v3'
config.private_token = 'your token'
end
def find_project_id_from_project_name(name)
Gitlab.projects(per_page: 100).select { |e|e.name == name }.first.id
end
project_id = find_project_id_from_project_name('project_name')
Gitlab.issues(project_id).each do |issue|
Gitlab.edit_issue(project_id, issue.id, title: 'delete', state_event: 'close', labels: 'deleted')
end
参照
GitLab gem RubyGems
https://rubygems.org/gems/gitlabGitLab gem GitHub
https://github.com/NARKOZ/gitlab