Skip to content

Commit dce8515

Browse files
authored
Fix | Show app renames even when resources are unchanged (#435)
* Show application as changed in the diff if name changed * Test | update integration-test for branch-1 target-1
1 parent 43fd6a6 commit dce8515

12 files changed

Lines changed: 185 additions & 7 deletions

File tree

integration-test/branch-1/target-1/output.html

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ <h1>Argo CD Diff Preview</h1>
6262
<pre>Deleted (1):
6363
- folder2 (-19)
6464

65-
Modified (2):
65+
Modified (3):
66+
± app1 -> app2
6667
± multi-source-app (+2|-2)
6768
± nginx-ingress (+1|-1)</pre>
6869

@@ -100,6 +101,15 @@ <h4 class="resource_header">Deployment: deploy-from-folder-two</h4>
100101

101102
</details>
102103

104+
<details>
105+
<summary>
106+
app1 -&gt; app2 (examples/list-generator/app/app-set.yaml)
107+
</summary>
108+
109+
<p><em>Application name changed, but rendered resources are unchanged</em></p>
110+
111+
</details>
112+
103113
<details>
104114
<summary>
105115
multi-source-app (examples/multi-source/app.yaml)

integration-test/branch-1/target-1/output.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ Summary:
55
Deleted (1):
66
- folder2 (-19)
77

8-
Modified (2):
8+
Modified (3):
9+
± app1 -> app2
910
± multi-source-app (+2|-2)
1011
± nginx-ingress (+1|-1)
1112
```
@@ -38,6 +39,14 @@ Modified (2):
3839
```
3940
</details>
4041

42+
<details>
43+
<summary>app1 -> app2 (examples/list-generator/app/app-set.yaml)</summary>
44+
<br>
45+
46+
_Application name changed, but rendered resources are unchanged_
47+
48+
</details>
49+
4150
<details>
4251
<summary>multi-source-app (examples/multi-source/app.yaml)</summary>
4352
<br>

integration-test/branch-1/target-2/output.html

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ <h1>Argo CD Diff Preview</h1>
6262
<pre>Deleted (1):
6363
- folder2 (-19)
6464

65-
Modified (1):
65+
Modified (2):
66+
± app1 -> app2
6667
± multi-source-app (+1|-1)</pre>
6768

6869
<div class="diffs">
@@ -99,6 +100,15 @@ <h4 class="resource_header">Deployment: deploy-from-folder-two</h4>
99100

100101
</details>
101102

103+
<details>
104+
<summary>
105+
app1 -&gt; app2 (examples/list-generator/app/app-set.yaml)
106+
</summary>
107+
108+
<p><em>Application name changed, but rendered resources are unchanged</em></p>
109+
110+
</details>
111+
102112
<details>
103113
<summary>
104114
multi-source-app (examples/multi-source/app.yaml)

integration-test/branch-1/target-2/output.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ Summary:
55
Deleted (1):
66
- folder2 (-19)
77

8-
Modified (1):
8+
Modified (2):
9+
± app1 -> app2
910
± multi-source-app (+1|-1)
1011
```
1112

@@ -37,6 +38,14 @@ Modified (1):
3738
```
3839
</details>
3940

41+
<details>
42+
<summary>app1 -> app2 (examples/list-generator/app/app-set.yaml)</summary>
43+
<br>
44+
45+
_Application name changed, but rendered resources are unchanged_
46+
47+
</details>
48+
4049
<details>
4150
<summary>multi-source-app (examples/multi-source/app.yaml)</summary>
4251
<br>

integration-test/branch-1/target-3/output.html

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ <h1>Argo CD Diff Preview</h1>
6262
<pre>Deleted (1):
6363
- folder2
6464

65-
Modified (2):
65+
Modified (3):
66+
± app1 -> app2
6667
± multi-source-app (+2|-2)
6768
± nginx-ingress (+1|-1)</pre>
6869

@@ -76,6 +77,15 @@ <h1>Argo CD Diff Preview</h1>
7677

7778
</details>
7879

80+
<details>
81+
<summary>
82+
app1 -&gt; app2 [<a href="https://argocd.example.com/applications/app1">link</a>] (examples/list-generator/app/app-set.yaml)
83+
</summary>
84+
85+
<p><em>Application name changed, but rendered resources are unchanged</em></p>
86+
87+
</details>
88+
7989
<details>
8090
<summary>
8191
multi-source-app [<a href="https://argocd.example.com/applications/multi-source-app">link</a>] (examples/multi-source/app.yaml)

integration-test/branch-1/target-3/output.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ Summary:
55
Deleted (1):
66
- folder2
77

8-
Modified (2):
8+
Modified (3):
9+
± app1 -> app2
910
± multi-source-app (+2|-2)
1011
± nginx-ingress (+1|-1)
1112
```
@@ -18,6 +19,14 @@ _Diff hidden because `--hide-deleted-app-diff` is enabled_
1819

1920
</details>
2021

22+
<details>
23+
<summary>app1 -> app2 [<a href="https://argocd.example.com/applications/app1">link</a>] (examples/list-generator/app/app-set.yaml)</summary>
24+
<br>
25+
26+
_Application name changed, but rendered resources are unchanged_
27+
28+
</details>
29+
2130
<details>
2231
<summary>multi-source-app [<a href="https://argocd.example.com/applications/multi-source-app">link</a>] (examples/multi-source/app.yaml)</summary>
2332
<br>

pkg/diff/html.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ func emptyReasonHTML(reason matching.EmptyReason) string {
105105
return "<p><em>Application rendered no resources</em></p>"
106106
case matching.EmptyReasonHiddenDiff:
107107
return "<p><em>Diff hidden because <code>--hide-deleted-app-diff</code> is enabled</em></p>"
108+
case matching.EmptyReasonNameOnlyChange:
109+
return "<p><em>Application name changed, but rendered resources are unchanged</em></p>"
108110
default:
109111
return "<p><em>Empty for unknown reason</em></p>"
110112
}

pkg/diff/html_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,21 @@ func TestHTMLSection_PrintHTMLSection_EmptyResources(t *testing.T) {
7878
}
7979
}
8080

81+
func TestHTMLSection_PrintHTMLSection_NameOnlyChange(t *testing.T) {
82+
section := HTMLSection{
83+
appName: "old-app -> new-app",
84+
filePath: "path/to/app",
85+
resources: []ResourceSection{},
86+
emptyReason: matching.EmptyReasonNameOnlyChange,
87+
}
88+
89+
result := section.printHTMLSection()
90+
91+
if !strings.Contains(result, "Application name changed, but rendered resources are unchanged") {
92+
t.Errorf("expected name-only change message, got:\n%s", result)
93+
}
94+
}
95+
8196
func TestHTMLSection_PrintHTMLSection_SkippedResource(t *testing.T) {
8297
section := HTMLSection{
8398
appName: "my-app",

pkg/diff/markdown.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ func emptyReasonMarkdown(reason matching.EmptyReason) string {
2323
return "_Application rendered no resources_"
2424
case matching.EmptyReasonHiddenDiff:
2525
return "_Diff hidden because `--hide-deleted-app-diff` is enabled_"
26+
case matching.EmptyReasonNameOnlyChange:
27+
return "_Application name changed, but rendered resources are unchanged_"
2628
default:
2729
return "_Empty for unknown reason_"
2830
}

pkg/diff/markdown_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,23 @@ func TestMarkdownSection_Build_EdgeCases(t *testing.T) {
373373
}
374374
})
375375

376+
t.Run("Name-only change", func(t *testing.T) {
377+
section := MarkdownSection{
378+
appName: "old-app -> new-app",
379+
filePath: "path.yaml",
380+
appURL: "",
381+
resources: []ResourceSection{},
382+
emptyReason: matching.EmptyReasonNameOnlyChange,
383+
}
384+
content, truncated := section.build(1000)
385+
if truncated {
386+
t.Errorf("Name-only change should not be truncated")
387+
}
388+
if !strings.Contains(content, "_Application name changed, but rendered resources are unchanged_") {
389+
t.Errorf("Should contain name-only change explanation")
390+
}
391+
})
392+
376393
t.Run("Content with trailing newlines", func(t *testing.T) {
377394
section := MarkdownSection{
378395
appName: "App",

0 commit comments

Comments
 (0)