LoginSignup
3
3

More than 5 years have passed since last update.

GitLab API | gitlab gem で 任意のプロジェクトの全ての Issue を疑似削除する

Posted at

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

参照

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3