diff --git a/AUTHORS b/AUTHORS index 8b050972..84fc3705 100644 --- a/AUTHORS +++ b/AUTHORS @@ -6,5 +6,6 @@ to this project (in alphabetical order): * Emanuel Danci * Vlad Temian * Justus Perlwitz +* Tushar Makkar * Your name could stand here :) diff --git a/gitfs/worker/sync.py b/gitfs/worker/sync.py index 75bb81e1..75f05911 100644 --- a/gitfs/worker/sync.py +++ b/gitfs/worker/sync.py @@ -166,11 +166,20 @@ def commit(self, jobs): message = jobs[0]['params']['message'] else: updates = set([]) + number_of_removal = 0 + number_of_additions = 0 for job in jobs: - updates = updates | set(job['params']['add']) - updates = updates | set(job['params']['remove']) - - message = "Update {} items".format(len(updates)) + removal_set = set(job['params']['remove']) + addition_set = set(job['params']['add']) + number_of_removal += len(removal_set) + number_of_additions += len(addition_set) + updates = updates | removal_set | addition_set + message = "Update {} items. ".format(len(updates)) + if number_of_additions: + message += "Added {} items. ".format(number_of_additions) + if number_of_removal: + message += "Removed {} items. ".format(number_of_removal) + message = message.strip() old_head = self.repository.head.target new_commit = self.repository.commit(message, self.author, diff --git a/tests/integrations/current/test_write.py b/tests/integrations/current/test_write.py index 818e351c..ee0ceeac 100644 --- a/tests/integrations/current/test_write.py +++ b/tests/integrations/current/test_write.py @@ -59,7 +59,7 @@ def test_delete_a_directory(self, gitfs_log): shutil.rmtree("{}/a_directory/".format(self.current_path)) with pull(self.sh): - self.assert_commit_message("Update 2 items") + self.assert_commit_message("Update 2 items. Removed 2 items.") self.assert_new_commit() assert os.path.exists(path) is False @@ -93,7 +93,7 @@ def test_link_a_file(self, gitfs_log): os.link(filename, link_name) with pull(self.sh): - self.assert_commit_message("Update 2 items") + self.assert_commit_message("Update 2 items. Added 2 items.") is_link = os.path.isfile(link_name) assert is_link is not False @@ -158,7 +158,7 @@ def test_create_embedded_directory(self, gitfs_log): assert os.path.exists(keep_file) self.assert_new_commit() - commit_msg = "Update 2 items" + commit_msg = "Update 2 items. Added 2 items." self.assert_commit_message(commit_msg) def test_create_directory_inside_an_already_existing_directory(self, gitfs_log): @@ -205,7 +205,7 @@ def test_create_embedded_directory_on_multiple_levels(self, gitfs_log): assert os.path.exists(keep_file) self.assert_new_commit() - commit_msg = "Update {} items".format(len(keep_files)) + commit_msg = "Update {} items. Added {} items.".format(len(keep_files), len(keep_files)) self.assert_commit_message(commit_msg) def test_create_embedded_directory_big_depth(self, gitfs_log): @@ -283,7 +283,7 @@ def test_fsync(self, gitfs_log): with pull(self.sh): self.assert_new_commit() - self.assert_commit_message("Update 1 items") + self.assert_commit_message("Update 1 items. Added 2 items.") def test_create(self, gitfs_log): filename = "{}/new_empty_file".format(self.current_path) @@ -357,7 +357,7 @@ def test_create_multiple_files(self, gitfs_log): self.assert_new_commit() with pull(self.sh): - self.assert_commit_message("Update {} items".format(no_of_files)) + self.assert_commit_message("Update {} items. Added {} items.".format(no_of_files, no_of_files)) def test_delete_file(self, gitfs_log): filename = "{}/deletable_file".format(self.current_path) diff --git a/tests/workers/test_sync.py b/tests/workers/test_sync.py index 075549d9..f7cd0994 100644 --- a/tests/workers/test_sync.py +++ b/tests/workers/test_sync.py @@ -190,7 +190,7 @@ def test_commit_with_more_than_one_job(self): repository=mocked_repo) worker.commit(jobs) - asserted_message = "Update 2 items" + asserted_message = "Update 2 items. Added 2 items. Removed 1 items." mocked_repo.commit.assert_called_once_with(asserted_message, author, author) assert mocked_repo.commits.update.call_count == 1