File tree 1 file changed +49
-0
lines changed
1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env ruby
2
+
3
+ def shorten_label ( label )
4
+ label = label . gsub ( /\@ .*$/ , "" )
5
+ label = label . gsub ( /github\. com/ , "" )
6
+ label = label . gsub ( /golang\. org/ , "" )
7
+ label
8
+ end
9
+
10
+ nodes = { }
11
+ edges = [ ]
12
+
13
+ next_node_id = 1
14
+
15
+ $stdin. read . each_line do |line |
16
+ src , dst = line . split ( " " )
17
+
18
+ if nodes . include? ( src )
19
+ src_id = nodes [ src ]
20
+ else
21
+ src_id = next_node_id
22
+ nodes [ src ] = src_id
23
+ next_node_id += 1
24
+ end
25
+
26
+ if nodes . include? ( dst )
27
+ dst_id = nodes [ dst ]
28
+ else
29
+ dst_id = next_node_id
30
+ nodes [ dst ] = dst_id
31
+ next_node_id += 1
32
+ end
33
+
34
+ edges . push ( [ src_id , dst_id ] )
35
+ end
36
+
37
+ puts "digraph go_mod_graph {"
38
+
39
+ puts " graph [layout = dot, rankdir = LR];"
40
+
41
+ nodes . each do |label , node_id |
42
+ puts " n#{ node_id } [label = \" #{ shorten_label ( label ) } \" ]" ;
43
+ end
44
+
45
+ edges . each do |src_id , dst_id |
46
+ puts " n#{ src_id } -> n#{ dst_id } ;"
47
+ end
48
+
49
+ puts "}"
You can’t perform that action at this time.
0 commit comments