Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## [0.4.5] - 2026-04-07

### Fixed

- Skip transfer, orphan cleanup, and hooks when no differences detected (#42)
- `pull` and `push` actions now early-exit the apply phase when no differences exist
- Eliminates expensive `Find.find` directory scans from `cleanup_orphans` on every run
- `force_hooks` option still executes hooks even without differences

## [0.4.4] - 2026-04-07

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
dotsync (0.4.4)
dotsync (0.4.5)
fileutils (~> 1.7.3)
find (~> 0.2.0)
listen (~> 3.9.0)
Expand Down
11 changes: 8 additions & 3 deletions lib/dotsync/actions/pull_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,14 @@ def execute(options = {})
end
end

transfer_mappings
cleanup_orphans
execute_hooks(force: options[:force_hooks])
if has_differences?
transfer_mappings
cleanup_orphans
execute_hooks(force: options[:force_hooks])
elsif options[:force_hooks]
execute_hooks(force: true)
end

action("Mappings pulled", icon: :done)
end

Expand Down
9 changes: 7 additions & 2 deletions lib/dotsync/actions/push_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@ def execute(options = {})
return unless confirm_action
end

transfer_mappings
execute_hooks(force: options[:force_hooks])
if has_differences?
transfer_mappings
execute_hooks(force: options[:force_hooks])
elsif options[:force_hooks]
execute_hooks(force: true)
end

action("Mappings pushed", icon: :done)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/dotsync/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Dotsync
VERSION = "0.4.4"
VERSION = "0.4.5"
end
44 changes: 44 additions & 0 deletions spec/dotsync/actions/pull_action_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,26 @@
expect(file_transfer2).to have_received(:transfer)
end

context "without differences" do
before do
File.write(File.join(mapping1.dest, "file1"), "src content")
File.write(mapping2.dest, "#{mapping2.src} content")
end

it "skips transfer, orphan cleanup, and hooks" do
subject

expect(file_transfer1).not_to have_received(:transfer)
expect(file_transfer2).not_to have_received(:transfer)
end

it "still shows mappings pulled message" do
expect(logger).to receive(:action).with("Mappings pulled", icon: :done)

subject
end
end

context "with user confirmation" do
context "when user accepts" do
before do
Expand Down Expand Up @@ -244,6 +264,30 @@
end
end

context "with hooks and no differences" do
let(:mapping_with_hooks) do
Dotsync::Mapping.new(
"src" => file2_src,
"dest" => file2_dest,
"hooks" => ["echo hook_ran"]
)
end
let(:mappings) { [mapping1, mapping_with_hooks] }

before do
File.write(File.join(mapping1.dest, "file1"), "src content")
File.write(mapping_with_hooks.dest, "#{mapping_with_hooks.src} content")
end

context "with force_hooks option" do
it "executes hooks even without differences" do
expect_any_instance_of(Dotsync::HookRunner).to receive(:execute).and_return([])

action.execute(apply: true, yes: true, force_hooks: true)
end
end
end

context "hooks in dry-run mode" do
let(:mapping_with_hooks) do
Dotsync::Mapping.new(
Expand Down
47 changes: 47 additions & 0 deletions spec/dotsync/actions/push_action_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,26 @@
expect(file_transfer2).to have_received(:transfer)
end

context "without differences" do
before do
File.write(mapping1.dest, "src1 content")
File.write(mapping2.dest, "#{mapping2.src} content")
end

it "skips transfer and hooks" do
subject

expect(file_transfer1).not_to have_received(:transfer)
expect(file_transfer2).not_to have_received(:transfer)
end

it "still shows mappings pushed message" do
expect(logger).to receive(:action).with("Mappings pushed", icon: :done)

subject
end
end

context "with user confirmation" do
context "when user accepts" do
before do
Expand Down Expand Up @@ -246,6 +266,33 @@
end
end

context "with hooks and no differences" do
let(:mapping_with_hooks) do
Dotsync::Mapping.new(
"src" => File.join(root, "src2"),
"dest" => File.join(root, "dest2"),
"force" => false,
"ignore" => [],
"hooks" => ["echo hook_ran"]
)
end
let(:mappings) { [mapping1, mapping_with_hooks] }

before do
File.write(mapping1.dest, "src1 content")
File.write(mapping_with_hooks.src, "#{mapping_with_hooks.src} content")
File.write(mapping_with_hooks.dest, "#{mapping_with_hooks.src} content")
end

context "with force_hooks option" do
it "executes hooks even without differences" do
expect_any_instance_of(Dotsync::HookRunner).to receive(:execute).and_return([])

action.execute(apply: true, yes: true, force_hooks: true)
end
end
end

context "hooks in dry-run mode" do
let(:mapping_with_hooks) do
Dotsync::Mapping.new(
Expand Down
Loading