Skip to content
This repository

Properly commit when the comment is the only thing changed. #41

Merged
merged 1 commit into from about 2 years ago

2 participants

Dylan Markow Alexander Simonov
Dylan Markow

Right now, the only way to change the comment on a zip file is to actually change the contents of the zip file in some way. This pull request adds a @storedComment variable (similar to @storedEntries) and updates the commit_required? method to check for a changed comment. Test included.

Alexander Simonov
Owner

Please update README for this feature.

Dylan Markow

I thought of this more as a bug fix than a feature, and I don't really see where in the README it would make sense to mention this behavior, unless you'd like it to be a configuration option. Let me know and I'll get it updated, thanks!

Alexander Simonov
Owner

Ok, I will rewrite README for it and many other features. Thank you for your bug fix.

Alexander Simonov simonoff merged commit 403cca6 into from
Alexander Simonov simonoff closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Apr 06, 2012
Dylan Markow Properly commit when the comment is the only thing changed. c60520f
This page is out of date. Refresh to see the latest.
3  lib/zip/zip_file.rb
@@ -73,6 +73,7 @@ def initialize(fileName, create = nil, buffer = false)
73 73
       end
74 74
       @create = create
75 75
       @storedEntries = @entrySet.dup
  76
+      @storedComment = @comment
76 77
       @restore_ownership = false
77 78
       @restore_permissions = false
78 79
       @restore_times = true
@@ -229,7 +230,7 @@ def commit_required?
229 230
       @entrySet.each do |e|
230 231
         return true if e.dirty
231 232
       end
232  
-      @entrySet != @storedEntries || @create == ZipFile::CREATE
  233
+      @comment != @storedComment || @entrySet != @storedEntries || @create == ZipFile::CREATE
233 234
     end
234 235
 
235 236
     # Searches for entry with the specified name. Returns nil if
8  test/ziptest.rb
@@ -1452,6 +1452,14 @@ def test_compound2
1452 1452
     end
1453 1453
   end
1454 1454
 
  1455
+  def test_changeComment
  1456
+    ZipFile.open(TEST_ZIP.zip_name) do |zf|
  1457
+      zf.comment = "my changed comment"
  1458
+    end
  1459
+    zfRead = ZipFile.open(TEST_ZIP.zip_name)
  1460
+    assert_equal("my changed comment", zfRead.comment)
  1461
+  end
  1462
+
1455 1463
   private
1456 1464
   def assert_contains(zf, entryName, filename = entryName)
1457 1465
     assert(zf.entries.detect { |e| e.name == entryName} != nil, "entry #{entryName} not in #{zf.entries.join(', ')} in zip file #{zf}")
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.