File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -25,18 +25,27 @@ def clone_or_fetch(remote_scm, callback)
25
25
26
26
status . exist? ? revert_and_pull ( remote_scm ) : clone_repository ( remote_scm )
27
27
28
+ clean_up_disk
29
+
28
30
callback . update ( 1 , 1 )
29
31
end
30
32
31
33
def clone_repository ( remote_scm )
32
34
run "rm -rf '#{ url } '"
33
- run "hg clone -U '#{ remote_scm . url } ' '#{ url } '"
35
+ run "hg clone '#{ remote_scm . url } ' '#{ url } '"
34
36
end
35
37
36
38
def revert_and_pull ( remote_scm )
37
39
branch_opts = "-r #{ remote_scm . branch_name } " if branch_name
38
40
run "cd '#{ url } ' && hg revert --all && hg pull #{ branch_opts } -u -y '#{ remote_scm . url } '"
39
41
end
42
+
43
+ def clean_up_disk
44
+ return unless FileTest . exist? ( url )
45
+
46
+ run "cd #{ url } && find . -maxdepth 1 -not -name .hg -not -name . -print0" \
47
+ ' | xargs -0 rm -rf --'
48
+ end
40
49
end
41
50
end
42
51
end
Original file line number Diff line number Diff line change 1
1
require 'spec_helper'
2
2
3
3
describe 'Hg::Scm' do
4
- it 'must pull hg repository' do
4
+ it 'must pull hg repository and clean up non .hg files ' do
5
5
with_hg_repository ( 'hg' ) do |src |
6
6
tmpdir do |dir |
7
7
dest = OhlohScm ::Factory . get_core ( scm_type : :hg , url : dir )
8
8
dest . status . wont_be :exist?
9
9
10
10
dest . scm . pull ( src . scm , TestCallback . new )
11
11
dest . status . must_be :exist?
12
+ Dir . entries ( dir ) . sort . must_equal [ '.' , '..' , '.hg' ]
12
13
13
14
# Commit some new code on the original and pull again
14
15
run_p "cd '#{ src . scm . url } ' && touch foo && hg add foo && hg commit -u test -m test"
15
16
src . activity . commits . last . message . must_equal "test\n "
16
17
17
18
dest . scm . pull ( src . scm , TestCallback . new )
19
+ Dir . entries ( dir ) . sort . must_equal [ '.' , '..' , '.hg' ]
18
20
end
19
21
end
20
22
end
You can’t perform that action at this time.
0 commit comments