Skip to content

Commit

Permalink
Merge pull request #78 from acant/bug/extra_file_changes
Browse files Browse the repository at this point in the history
Working on removing the extra file changes and extra notifications
  • Loading branch information
nesquena committed Apr 10, 2014
2 parents 2b1d616 + c01d860 commit 63ec481
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/gitdocs/repository.rb
Expand Up @@ -192,7 +192,7 @@ def push(last_synced_oid, message='Auto-commit from gitdocs')

#add and commit
Dir.glob(File.join(root, '**', '*'))
.select { |x| File.directory?(x) && Dir.glob("#{x}/*").empty? }
.select { |x| File.directory?(x) && Dir.glob("#{x}/*", File::FNM_DOTMATCH).size == 2 }
.each { |x| FileUtils.touch(File.join(x, '.gitignore')) }
Dir.chdir(root) do
@rugged.index.add_all
Expand Down
25 changes: 23 additions & 2 deletions test/repository_test.rb
Expand Up @@ -21,7 +21,6 @@
let(:remote_repo) { Rugged::Repository.init_at('tmp/unit/remote', :bare) }
let(:local_repo) { Rugged::Repository.new(local_repo_path) }


describe 'initialize' do
subject { repository }

Expand Down Expand Up @@ -252,7 +251,7 @@
)
end
it { subject.must_equal :ok }
it { subject ; File.exists?(File.join(local_repo_path, 'file2')).must_equal true }
it { subject ; local_file_exist?('file2').must_equal true }
it { subject ; commit_count(local_repo).must_equal 2 }
end
end
Expand Down Expand Up @@ -292,6 +291,7 @@
)
end
it { subject.must_equal :nothing }
it { subject ; commit_count(local_repo).must_equal 1 }
end

describe 'and there is a conflicted file to push' do
Expand All @@ -315,6 +315,21 @@
it { subject ; head_tree_files(remote_repo).must_include 'directory' }
end

describe 'and there is a directory with a hidden file' do
before do
FileUtils.mkdir_p(File.join(local_repo_path, 'directory'))
write('directory/.hidden', '')
end
it { subject.must_equal :ok }
it { subject ; local_file_exist?('directory', '.gitignore').must_equal false }
it { subject ; commit_count(local_repo).must_equal 2 }
it { subject ; commit_count(remote_repo).must_equal 2 }
it { subject ; head_commit(remote_repo).message.must_equal "message\n" }
it { subject ; head_tree_files(remote_repo).count.must_equal 2 }
it { subject ; head_tree_files(remote_repo).must_include 'file1' }
it { subject ; head_tree_files(remote_repo).must_include 'directory' }
end

describe 'and there is an existing file update to push' do
before { write('file1', 'deadbeef') }
it { subject.must_equal :ok }
Expand Down Expand Up @@ -354,6 +369,7 @@

describe 'and this is nothing to push' do
it { subject.must_equal :nothing }
it { subject ; commit_count(local_repo).must_equal 1 }
end

describe 'and there is a conflicted commit to push' do
Expand Down Expand Up @@ -577,9 +593,14 @@ def head_tree_files(repo)
head_commit(repo).tree.map { |x| x[:name] }
end

# NOTE: This method is ignoring hidden files.
def local_repo_files
Dir.chdir(local_repo_path) do
Dir.glob('*')
end
end

def local_file_exist?(*path_elements)
File.exist?(File.join(local_repo_path, *path_elements))
end
end

0 comments on commit 63ec481

Please sign in to comment.