Skip to content

Commit fa62745

Browse files
committed
Prepare SFTP transfer layout regression patch
1 parent 31cbefa commit fa62745

1 file changed

Lines changed: 116 additions & 0 deletions

File tree

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: SFTP transfer layout patch carrier
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
carrier:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- run: |
14+
python3 <<'PY'
15+
from pathlib import Path
16+
17+
content_path = Path("Sources/SelectiveRemote/ContentView.swift")
18+
content = content_path.read_text()
19+
20+
detail_old = ''' private var detail: some View {
21+
ZStack {
22+
'''
23+
detail_new = ''' private var detail: some View {
24+
ZStack(alignment: .topLeading) {
25+
'''
26+
if detail_old not in content:
27+
raise SystemExit("detail ZStack marker not found")
28+
content = content.replace(detail_old, detail_new, 1)
29+
30+
# Historical reusable runner inserts this case itself. Remove the
31+
# current oddly-indented copy so the runner can add exactly one case.
32+
pane_block = ''' case let .pane(paneID):
33+
if let tab = model.sftpWorkspace.tab(containing: paneID) {
34+
model.sftpWorkspace.selectedTabID = tab.id
35+
}
36+
setMainArea(.sftp)
37+
'''
38+
if pane_block not in content:
39+
raise SystemExit("existing pane case block not found")
40+
content = content.replace(pane_block, "", 1)
41+
content_path.write_text(content)
42+
43+
workspace_path = Path("Sources/SelectiveRemote/SFTPWorkspace.swift")
44+
source = workspace_path.read_text()
45+
46+
root_marker = ''' }
47+
.sheet(item: $connectionRequest) { request in
48+
'''
49+
root_replacement = ''' }
50+
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
51+
.sheet(item: $connectionRequest) { request in
52+
'''
53+
if root_marker not in source:
54+
raise SystemExit("workspace root frame marker not found")
55+
source = source.replace(root_marker, root_replacement, 1)
56+
57+
disclosure_start = ' DisclosureGroup(isExpanded: $showsTransfers) {\n'
58+
label_marker = ' } label: {\n'
59+
start = source.find(disclosure_start)
60+
if start < 0:
61+
raise SystemExit("transfer DisclosureGroup start not found")
62+
body_start = start + len(disclosure_start)
63+
label = source.find(label_marker, body_start)
64+
if label < 0:
65+
raise SystemExit("transfer DisclosureGroup label not found")
66+
old_body = source[body_start:label]
67+
if 'ScrollView(.vertical)' in old_body:
68+
raise SystemExit("transfer drawer already scrollable")
69+
indented_body = ''.join(
70+
(' ' + line) if line.strip() else line
71+
for line in old_body.splitlines(keepends=True)
72+
)
73+
new_body = (
74+
' ScrollView(.vertical) {\n'
75+
+ indented_body
76+
+ ' }\n'
77+
+ ' .frame(maxHeight: 220)\n'
78+
)
79+
source = source[:body_start] + new_body + source[label:]
80+
workspace_path.write_text(source)
81+
82+
tests = Path("Tests/SelectiveRemoteTests/SFTPWorkspaceSmartLinksTests.swift")
83+
test_text = tests.read_text()
84+
marker = '@Test("SFTP transfer drawer keeps the workspace anchored below the title bar")'
85+
if marker not in test_text:
86+
test_text += '''
87+
88+
@Test("SFTP transfer drawer keeps the workspace anchored below the title bar")
89+
func sftpTransferDrawerKeepsTopAnchoredLayout() throws {
90+
let projectRoot = URL(fileURLWithPath: #filePath)
91+
.deletingLastPathComponent()
92+
.deletingLastPathComponent()
93+
.deletingLastPathComponent()
94+
let workspace = try String(
95+
contentsOf: projectRoot
96+
.appendingPathComponent("Sources/SelectiveRemote/SFTPWorkspace.swift"),
97+
encoding: .utf8
98+
)
99+
let content = try String(
100+
contentsOf: projectRoot
101+
.appendingPathComponent("Sources/SelectiveRemote/ContentView.swift"),
102+
encoding: .utf8
103+
)
104+
105+
#expect(content.contains(
106+
"private var detail: some View {\\n ZStack(alignment: .topLeading) {"
107+
))
108+
#expect(workspace.contains(
109+
".frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)\\n .sheet(item: $connectionRequest)"
110+
))
111+
#expect(workspace.contains("ScrollView(.vertical)"))
112+
#expect(workspace.contains(".frame(maxHeight: 220)"))
113+
}
114+
'''
115+
tests.write_text(test_text)
116+
PY

0 commit comments

Comments
 (0)