summaryrefslogtreecommitdiff
path: root/scripts/periupport_conv
blob: aa1956d71fbc309f36fbd766515ded1f1149d1ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#! /bin/sh

[ $# -ne 2 ] && echo "$0 <ticket text output> <dest path>" && exit 0

SRC="$1"
DST="$2"

# FIXME: ensure this is not already existing in another task
uuid_cmd="cat /proc/sys/kernel/random/uuid"

gawk -F: -v dst="$DST" -v cmd="$uuid_cmd" '
	function make_filename(nam) {
			gsub(/[: /]+/, "_", nam)
			sub(/_$/, "", nam)
			return nam
		}
	$1 == "B" {
			bsp_id = $2
			desc = substr($0, 46)
			bsp_desc[bsp_id] = desc
			match(desc, /.*:/)
			task_key = substr(desc, RSTART, RLENGTH)
			gsub(/"/, "´", task_key)
			tasks[task_key][bsp_id] = bsp_id
		}

	$1 == "U" {
			upstream[bsp_id] = $2
			upstream_desc[bsp_id] = substr($0, 46)
		}

	$1 == "*"	{ $1 = ""; gsub(/"/, "´"); comment[bsp_id] = $0 }

	/^Priority: N/	{ exit }

	END {
			FS = " "
			for (task in tasks) {

				cmd | getline uuid; close(cmd);
				F = dst "/" make_filename(task) ".yaml"

				delete(sorted_idx)
				asorti(tasks[task], sorted_idx)

				print "title: \"Upport " task "\"" > F
				print "team: MM" >> F
				print "key: " uuid >> F
				print "status: Active" >> F
				print "" >> F
				print "relationships:\n" >> F

				print "bsp-commits:" >> F
				for (idx in sorted_idx) {
					commit = tasks[task][sorted_idx[idx]]
					print "  -" commit >> F
					print "    # " bsp_desc[commit] >> F
				}
				print "" >> F

				print "upstream:" >> F
				for (idx in sorted_idx) {
					commit = tasks[task][sorted_idx[idx]]
					if (upstream[commit])
						print "  - torvalds:" upstream[commit] " # " upstream_desc[commit] >> F
				}
				print "" >> F

				print "comments:" >> F
				for (idx in sorted_idx) {
					commit = tasks[task][sorted_idx[idx]]
					if (comment[commit])
						print "  - \"" substr(commit, 2) ":" substr(comment[commit], 2) "\"" >> F
				}
			}
	}
' $SRC