Skip to content

Commit 9ab5b40

Browse files
tbriskerares
authored andcommitted
Add task to set column according to tags
This also solves the problem of having to hardcoding tags that prevent issues from being moved out of the wip column
1 parent 90fac26 commit 9ab5b40

File tree

4 files changed

+49
-7
lines changed

4 files changed

+49
-7
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
Gemfile.lock
22
.idea
33
profiles/*.yml
4+
.ruby-version
5+
.ruby-gemset

profiles/default.yml.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ whitelist:
3131
- 100-sync_bz_link_from_redmine
3232
- 150-set_assignee_according_to_redmine
3333
- 200-set_column_according_to_redmine
34+
- 250-set_column_according_to_tags
3435
- 400-sync_bz_bugs_to_triage
3536

3637
# you can further limit what tasks will not be executed by blacklist
@@ -71,6 +72,12 @@ configuration:
7172
# never move task to backlog automatically, once it's already in progress
7273
Backlog:
7374
column: ['Work in progress']
75+
250-set_column_according_to_tags:
76+
map:
77+
waiting_on_contributor: 'Work in progress'
78+
needs_rebase: 'Work in progress'
79+
waiting_on_packaging: 'Blocked'
80+
blocked_by_another_pr: 'Blocked'
7481
400-sync_bz_bugs_to_triage:
7582
color: 'amber'
7683
tag: 'Triage'

tasks/200-set_column_according_to_redmine.rb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,6 @@
4444

4545
name = kanboard_columns.sort { |a,b| map.keys.index(a.first) <=> map.keys.index(b.first) }.first.try(:first)
4646

47-
# name overrides based on task tags
48-
# TODO following override would be good to make configurable
49-
if name == 'Review' && (task.tags.include?('needs_rebase') || task.tags.include?('waiting_on_contributor'))
50-
logger.info 'Overriding new state to Work in progress because of tag needs_rebase or waiting_on_contributor'
51-
name = 'Work in progress'
52-
end
53-
5447
change_column = task.column_id != KanboardColumn.find_by_name(task.project_id, name).id
5548
blockers = task_configuration['blockers'][name] || {}
5649
blocked_by_tag = blockers['tag'].kind_of?(Array) && task.tags.any? { |tag| blockers['tag'].include?(tag) }
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# settings format
2+
# map:
3+
# mapping of kanboard tags to kanboard columns
4+
#
5+
# blockers:
6+
# we ca prevent moving to specific column by setting a blocker based on tag or current column, e.g. don't move task to
7+
# Review column if "needs_rebase" tag is set for the task, or don't move the task to Backlog if it's already in Work in progress
8+
task_configuration = {
9+
'map' => {},
10+
}.merge(task_configuration)
11+
map = task_configuration['map']
12+
13+
project.current_tasks.each do |task|
14+
logger.info "Processing #{task.title}"
15+
16+
next if task.tags.empty?
17+
18+
logger.info "... found #{task.tags.size} tags"
19+
20+
kanboard_columns = task.tags.map do |tag|
21+
found = map[tag]
22+
logger.debug "Couldn't find column name for #{tag}" if found.nil?
23+
found
24+
end
25+
kanboard_columns.compact!
26+
27+
next if kanboard_columns.empty?
28+
29+
logger.debug "Found following columns for this task: #{kanboard_columns.join(', ')}"
30+
name = kanboard_columns.first
31+
32+
change_column = task.column_id != KanboardColumn.find_by_name(task.project_id, name).id
33+
34+
if change_column
35+
logger.warn "Setting the column #{name} for this task"
36+
task.move_to_column(name)
37+
end
38+
39+
logger.debug "\n"
40+
end

0 commit comments

Comments
 (0)