Skip to content

Commit

Permalink
Resolve HEAD in tests
Browse files Browse the repository at this point in the history
The symbolic ref HEAD is valid in all repositories, so we manually
resolve it to a SHA1 hash. Each hash is unique for each repository, so
we can catch bugs where the wrong treeish is used in a submodule.
  • Loading branch information
roehling committed Jan 26, 2021
1 parent cb3d441 commit b16d2d8
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ check_tar_content()
@test "simple repo, archive with prefix" {
create_repo alpha
cd alpha
run_git_archive_all -o test.tar --prefix=prefix/
run_git_archive_all -o test.tar --prefix=prefix/ $(git rev-parse HEAD)
local tar_files
repo_files tar_files alpha prefix/
check_tar_content test.tar "${tar_files[@]}"
Expand All @@ -192,7 +192,7 @@ check_tar_content()
@test "simple repo, archive with prefix and path spec" {
create_repo alpha
cd alpha
run_git_archive_all -o test.tar --prefix=prefix/ HEAD alpha_folder/
run_git_archive_all -o test.tar --prefix=prefix/ $(git rev-parse HEAD) alpha_folder/
local tar_files
repo_files tar_files alpha prefix/
filter_array tar_files prefix/alpha_folder/
Expand All @@ -202,7 +202,7 @@ check_tar_content()
@test "simple repo, fail on missing path spec" {
create_repo alpha
cd alpha
! run_git_archive_all -o test.tar HEAD beta
! run_git_archive_all -o test.tar $(git rev-parse HEAD) beta
}

@test "simple repo, file names with non-ASCII characters" {
Expand All @@ -218,7 +218,7 @@ check_tar_content()
@test "simple repo, archive with newline in prefix" {
create_repo alpha
cd alpha
run_git_archive_all -o test.tar --prefix=pre$'\n'fix/
run_git_archive_all -o test.tar --prefix=pre$'\n'fix/ $(git rev-parse HEAD)
local tar_files
repo_files tar_files alpha pre$'\n'fix/
check_tar_content test.tar "${tar_files[@]}"
Expand All @@ -229,7 +229,7 @@ check_tar_content()
create_repo beta
add_submodule alpha beta
cd alpha
run_git_archive_all -o test.tar
run_git_archive_all -o test.tar $(git rev-parse HEAD)
local tar_files=(.gitmodules)
repo_files tar_files+ alpha
repo_files tar_files+ beta beta/
Expand All @@ -241,7 +241,7 @@ check_tar_content()
create_repo beta
add_submodule alpha beta
cd alpha
run_git_archive_all -o test.tar.gz
run_git_archive_all -o test.tar.gz $(git rev-parse HEAD)
local tar_files=(.gitmodules)
repo_files tar_files+ alpha
repo_files tar_files+ beta beta/
Expand All @@ -254,7 +254,7 @@ check_tar_content()
create_repo beta
add_submodule alpha beta
cd alpha
run_git_archive_all -o test.tar --prefix=prefix/
run_git_archive_all -o test.tar --prefix=prefix/ $(git rev-parse HEAD)
local tar_files=(prefix/.gitmodules)
repo_files tar_files+ alpha prefix/
repo_files tar_files+ beta prefix/beta/
Expand All @@ -266,7 +266,7 @@ check_tar_content()
create_repo beta
add_submodule alpha beta
cd alpha
run_git_archive_all -o test.tar --prefix=prefix/ HEAD alpha_folder
run_git_archive_all -o test.tar --prefix=prefix/ $(git rev-parse HEAD) alpha_folder
local tar_files
repo_files tar_files alpha prefix/
filter_array tar_files prefix/alpha_folder/
Expand All @@ -279,7 +279,7 @@ check_tar_content()
create_repo beta
add_submodule alpha beta
cd alpha
run_git_archive_all -o test.tar HEAD beta/beta_folder
run_git_archive_all -o test.tar $(git rev-parse HEAD) beta/beta_folder
local tar_files
repo_files tar_files beta beta/
filter_array tar_files beta/beta_folder/
Expand All @@ -294,7 +294,7 @@ check_tar_content()
create_repo beta
add_submodule alpha beta "space umlaut ÄÖÜäöü"
cd alpha
run_git_archive_all -o test.tar
run_git_archive_all -o test.tar $(git rev-parse HEAD)
local tar_files=()
repo_files tar_files+ alpha
repo_files tar_files+ beta "space umlaut ÄÖÜäöü"/
Expand All @@ -307,7 +307,7 @@ check_tar_content()
create_repo beta
add_submodule alpha beta
cd alpha
run_git_archive_all -o test.tar --prefix=pre$'\n'fix/
run_git_archive_all -o test.tar --prefix=pre$'\n'fix/ $(git rev-parse HEAD)
local tar_files=(pre$'\n'fix/.gitmodules)
repo_files tar_files+ alpha pre$'\n'fix/
repo_files tar_files+ beta pre$'\n'fix/beta/
Expand All @@ -319,7 +319,7 @@ check_tar_content()
create_repo beta
add_submodule alpha beta
cd alpha
run_git_archive_all -o test.tar --prefix=pre$'\n'fix/ HEAD beta/beta_folder
run_git_archive_all -o test.tar --prefix=pre$'\n'fix/ $(git rev-parse HEAD) beta/beta_folder
local tar_files
repo_files tar_files beta pre$'\n'fix/beta/
filter_array tar_files pre$'\n'fix/beta/beta_folder/
Expand Down Expand Up @@ -359,7 +359,7 @@ check_tar_content()
add_submodule alpha beta
cd alpha
git submodule update --init --recursive
run_git_archive_all -o test.tar --fail-missing
run_git_archive_all -o test.tar --fail-missing $(git rev-parse HEAD)
local tar_files=(.gitmodules beta/.gitmodules)
repo_files tar_files+ alpha
repo_files tar_files+ beta beta/
Expand All @@ -375,7 +375,7 @@ check_tar_content()
add_submodule alpha beta
cd alpha
git submodule update --init --recursive
run_git_archive_all -o test.tar --fail-missing --no-recursive
run_git_archive_all -o test.tar --fail-missing --no-recursive $(git rev-parse HEAD)
local tar_files=(.gitmodules beta/.gitmodules)
repo_files tar_files+ alpha
repo_files tar_files+ beta beta/
Expand All @@ -389,7 +389,7 @@ check_tar_content()
add_submodule beta gamma
add_submodule alpha beta
cd alpha
! run_git_archive_all -o test.tar --fail-missing
! run_git_archive_all -o test.tar --fail-missing $(git rev-parse HEAD)
run_git_archive_all -o test.tar
local tar_files=(.gitmodules beta/.gitmodules)
repo_files tar_files+ alpha
Expand All @@ -405,7 +405,7 @@ check_tar_content()
add_submodule alpha beta
cd alpha
git submodule update --init --recursive
run_git_archive_all -o test.tar --fail-missing --prefix=prefix/
run_git_archive_all -o test.tar --fail-missing --prefix=prefix/ $(git rev-parse HEAD)
local tar_files=(prefix/.gitmodules prefix/beta/.gitmodules)
repo_files tar_files+ alpha prefix/
repo_files tar_files+ beta prefix/beta/
Expand All @@ -421,7 +421,7 @@ check_tar_content()
add_submodule alpha beta
cd alpha
git submodule update --init --recursive
run_git_archive_all -o test.tar --fail-missing --no-recursive HEAD beta/gamma/gamma_folder
run_git_archive_all -o test.tar --fail-missing --no-recursive $(git rev-parse HEAD) beta/gamma/gamma_folder
local tar_files=()
check_tar_content test.tar "${tar_files[@]}"
}
Expand All @@ -434,12 +434,12 @@ check_tar_content()
add_submodule alpha beta
cd alpha
git submodule update --init --recursive
run_git_archive_all -o test.tar --fail-missing --prefix=prefix/ HEAD beta/gamma/gamma_folder
run_git_archive_all -o test.tar --fail-missing --prefix=prefix/ $(git rev-parse HEAD) beta/gamma/gamma_folder
local tar_files
repo_files tar_files gamma prefix/beta/gamma/
filter_array tar_files prefix/beta/gamma/gamma_folder/
check_tar_content test.tar "${tar_files[@]}"
run_git_archive_all -o test.tar --fail-missing --prefix=prefix/ HEAD beta/gamma
run_git_archive_all -o test.tar --fail-missing --prefix=prefix/ $(git rev-parse HEAD) beta/gamma
repo_files tar_files gamma prefix/beta/gamma/
check_tar_content test.tar "${tar_files[@]}"
}
Expand All @@ -451,12 +451,12 @@ check_tar_content()
add_submodule alpha beta
cd alpha
git submodule update --init --recursive
run_git_archive_all -o test.tar --fail-missing HEAD beta/gamma/gamma_folder
run_git_archive_all -o test.tar --fail-missing $(git rev-parse HEAD) beta/gamma/gamma_folder
local tar_files
repo_files tar_files gamma beta/gamma/
filter_array tar_files beta/gamma/gamma_folder/
check_tar_content test.tar "${tar_files[@]}"
run_git_archive_all -o test.tar --fail-missing HEAD beta/gamma
run_git_archive_all -o test.tar --fail-missing $(git rev-parse HEAD) beta/gamma
repo_files tar_files gamma beta/gamma/
check_tar_content test.tar "${tar_files[@]}"
}
Expand All @@ -469,7 +469,7 @@ check_tar_content()
add_submodule alpha beta
cd alpha
git submodule update --init --recursive
run_git_archive_all -o test.tar --fail-missing --prefix=pre$'\n'fix/
run_git_archive_all -o test.tar --fail-missing --prefix=pre$'\n'fix/ $(git rev-parse HEAD)
local tar_files=(pre$'\n'fix/.gitmodules pre$'\n'fix/beta/.gitmodules)
repo_files tar_files+ alpha pre$'\n'fix/
repo_files tar_files+ beta pre$'\n'fix/beta/
Expand Down

0 comments on commit b16d2d8

Please sign in to comment.