fix(compress): preserve dotfile name when generating zip archive#1485
fix(compress): preserve dotfile name when generating zip archive#1485toller892 wants to merge 1 commit into
Conversation
Compressing a dot file or directory such as `.test` previously produced `.zip` instead of `.test.zip`. The cause is that `filepath.Ext` treats a leading-dot basename (e.g. `.test`) as its entire extension, so trimming it leaves an empty string and the resulting zip name becomes just `.zip`. When stripping the extension leaves an empty or dot-only basename, fall back to the original name so the zip preserves the source identifier. Fixes yorukot#1470
|
🎉 Thank you for your first contribution to superfile! We’re really excited to have you here 🙌 A maintainer might ask you to make a few changes before we can merge this PR. 👉 Please also take a moment to review our Contribution Guide If you have any questions, feel free to open a Discussion or just ask in the comments! |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
Dotfile zip archive naming fix
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
the bug is popular |
|
This issue has been fixed by @xelavopelk in #1475. But still, thanks for your effort! |
|
I noticed that the previous fix doesn't cover the test edge case. I’d love to go ahead and merge your PR, so could you please take a look and resolve the conflict? Thanks! |
|
@toller892 , your solution is the best! Just resolve merge conflict! |
getZipArchiveNameproduces.zip(no source name) when compressing a dot file or directory such as.test. The root cause is that Go'sfilepath.Extreturns the entire leading-dot basename as the extension, sostrings.TrimSuffixstrips everything and we're left with.zip.When stripping the extension yields an empty or dot-only basename, fall back to the original name so the resulting zip preserves the source identifier.
Cases covered by the new unit tests:
.test→.test.zip(was.zip)..test→..test.zip(was..zip)test.txt→test.zip(unchanged).test.txt→.test.zip(unchanged)test→test.zip(unchanged)Fixes #1470
Summary by CodeRabbit
Bug Fixes
Tests