@@ -69,12 +69,12 @@ var runCmd = &cobra.Command{
69
69
if len (args ) == 1 {
70
70
dir = args [0 ]
71
71
}
72
- diffMap , err := gitkustomizediff .Run (dir , opts )
72
+ res , err := gitkustomizediff .Run (dir , opts )
73
73
if err != nil {
74
74
fmt .Printf ("%+v\n " , err )
75
75
}
76
76
77
- printDiffMap (dir , opts , diffMap )
77
+ printRunResult (dir , opts , res )
78
78
79
79
return nil
80
80
},
@@ -93,36 +93,40 @@ func init() {
93
93
runCmd .PersistentFlags ().BoolVar (& runOpts .allowDirty , "allow-dirty" , false , "allow dirty tree" )
94
94
}
95
95
96
- func printDiffMap (dirPath string , opts gitkustomizediff.RunOpts , diffMap * gitkustomizediff.DiffMap ) {
97
- dirs := diffMap .Dirs ()
96
+ func printRunResult (dirPath string , opts gitkustomizediff.RunOpts , res * gitkustomizediff.RunResult ) {
97
+ dirs := res . DiffMap .Dirs ()
98
98
fmt .Printf ("# Git Kustomize Diff\n \n " )
99
+
100
+ fmt .Printf ("%s...%s\n \n " , res .BaseCommit , res .TargetCommit )
101
+
102
+ fmt .Printf ("<details><summary>Options</summary>\n \n " )
99
103
fmt .Println ("| name | value |" )
100
104
fmt .Println ("|-|-|" )
101
105
fmt .Printf ("| dir | %s |\n " , dirPath )
102
106
fmt .Printf ("| base | %s |\n " , opts .Base )
103
107
fmt .Printf ("| target | %s |\n " , opts .Target )
104
- fmt .Println ( " " )
108
+ fmt .Printf ( " \n </details> \n \n " )
105
109
106
- fmt .Printf ("## Target Kustomizations\n \n " )
110
+ fmt .Printf ("<details><summary> Target Kustomizations</summary> \n \n " )
107
111
if len (dirs ) > 0 {
108
112
fmt .Printf ("```\n %s\n ```\n " , strings .Join (dirs , "\n " ))
109
113
} else {
110
114
fmt .Println ("N/A" )
111
115
}
112
- fmt .Println ( " " )
116
+ fmt .Printf ( " \n </details> \n \n " )
113
117
114
- fmt .Printf ("## Diff\n \n " )
115
- lines := make ([]string , 0 )
118
+ found := false
116
119
for _ , dir := range dirs {
117
- text := diffMap .Results [dir ].AsMarkdown ()
120
+ text := res . DiffMap .Results [dir ].AsMarkdown ()
118
121
if text != "" {
119
- lines = append (lines , fmt .Sprintf ("### %s:\n %s" , dir , text ))
122
+ fmt .Printf ("## %s\n \n " , dir )
123
+ fmt .Printf ("<details><summary>diff</summary>\n \n " )
124
+ fmt .Println (text )
125
+ fmt .Printf ("\n </details>\n \n " )
126
+ found = true
120
127
}
121
128
}
122
- if len (lines ) > 0 {
123
- fmt .Println (strings .Join (lines , "\n " ))
124
- } else {
129
+ if ! found {
125
130
fmt .Println ("N/A" )
126
131
}
127
- fmt .Println ("" )
128
132
}
0 commit comments