Navigation Menu

Skip to content

Commit

Permalink
Fixed git submodule initialization for older git versions (< 1.5.6).
Browse files Browse the repository at this point in the history
Use `git submodule init && git submodule update` instead of
`git submodule update --init`. The latter was added in git 1.5.6, which is
newer than the default git version in Ubuntu 8.04 LTS (1.5.4.3).
  • Loading branch information
ktheory authored and jbarnette committed Jan 4, 2010
1 parent 749ab8f commit f6f98fd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
6 changes: 4 additions & 2 deletions lib/vlad/git.rb
Expand Up @@ -20,7 +20,8 @@ def checkout(revision, destination)
"#{git_cmd} checkout -q origin",
"#{git_cmd} fetch",
"#{git_cmd} reset --hard #{revision}",
"#{git_cmd} submodule update --init",
"#{git_cmd} submodule init",
"#{git_cmd} submodule update",
"#{git_cmd} branch -f deployed-#{revision} #{revision}",
"#{git_cmd} checkout deployed-#{revision}",
"cd -"
Expand All @@ -29,7 +30,8 @@ def checkout(revision, destination)
[ "rm -rf #{destination}",
"#{git_cmd} clone #{repository} #{destination}",
"cd #{destination}",
"#{git_cmd} submodule update --init",
"#{git_cmd} submodule init",
"#{git_cmd} submodule update",
"#{git_cmd} checkout -f -b deployed-#{revision} #{revision}",
"cd -"
].join(" && ")
Expand Down
12 changes: 6 additions & 6 deletions test/test_vlad_git.rb
Expand Up @@ -18,34 +18,34 @@ def setup
# Checkout the way the default :update task invokes the method
def test_checkout
cmd = @scm.checkout 'head', '/the/scm/path'
assert_equal 'rm -rf /the/scm/path/repo && git clone git@myhost:/home/john/project1 /the/scm/path/repo && cd /the/scm/path/repo && git submodule update --init && git checkout -f -b deployed-HEAD HEAD && cd -', cmd
assert_equal 'rm -rf /the/scm/path/repo && git clone git@myhost:/home/john/project1 /the/scm/path/repo && cd /the/scm/path/repo && git submodule init && git submodule update && git checkout -f -b deployed-HEAD HEAD && cd -', cmd
end

# (fast-mode) Checkout the way the default :update task invokes the method
def test_checkout_fast
cmd = @scm_fast.checkout 'head', '/the/scm/path'
assert_equal 'cd /the/scm/path/repo && git checkout -q origin && git fetch && git reset --hard HEAD && git submodule update --init && git branch -f deployed-HEAD HEAD && git checkout deployed-HEAD && cd -', cmd
assert_equal 'cd /the/scm/path/repo && git checkout -q origin && git fetch && git reset --hard HEAD && git submodule init && git submodule update && git branch -f deployed-HEAD HEAD && git checkout deployed-HEAD && cd -', cmd
end

# This is not how the :update task invokes the method
def test_checkout_revision
# Checkout to the current directory
cmd = @scm.checkout 'master', '.'
assert_equal 'rm -rf ./repo && git clone git@myhost:/home/john/project1 ./repo && cd ./repo && git submodule update --init && git checkout -f -b deployed-master master && cd -', cmd
assert_equal 'rm -rf ./repo && git clone git@myhost:/home/john/project1 ./repo && cd ./repo && git submodule init && git submodule update && git checkout -f -b deployed-master master && cd -', cmd

# Checkout to a relative path
cmd = @scm.checkout 'master', 'some/relative/path'
assert_equal 'rm -rf some/relative/path/repo && git clone git@myhost:/home/john/project1 some/relative/path/repo && cd some/relative/path/repo && git submodule update --init && git checkout -f -b deployed-master master && cd -', cmd
assert_equal 'rm -rf some/relative/path/repo && git clone git@myhost:/home/john/project1 some/relative/path/repo && cd some/relative/path/repo && git submodule init && git submodule update && git checkout -f -b deployed-master master && cd -', cmd
end

# (fast-mode) This is not how the :update task invokes the method
def test_checkout_revision_fast
# Checkout to the current directory
cmd = @scm_fast.checkout 'master', '.'
assert_equal 'cd ./repo && git checkout -q origin && git fetch && git reset --hard master && git submodule update --init && git branch -f deployed-master master && git checkout deployed-master && cd -', cmd
assert_equal 'cd ./repo && git checkout -q origin && git fetch && git reset --hard master && git submodule init && git submodule update && git branch -f deployed-master master && git checkout deployed-master && cd -', cmd

cmd = @scm_fast.checkout 'master', 'some/relative/path'
assert_equal 'cd some/relative/path/repo && git checkout -q origin && git fetch && git reset --hard master && git submodule update --init && git branch -f deployed-master master && git checkout deployed-master && cd -', cmd
assert_equal 'cd some/relative/path/repo && git checkout -q origin && git fetch && git reset --hard master && git submodule init && git submodule update && git branch -f deployed-master master && git checkout deployed-master && cd -', cmd
end

def test_export
Expand Down

0 comments on commit f6f98fd

Please sign in to comment.