private fun install_from_git(git_repo, name: String, version: nullable String)
do
check_git
var target_dir = nitpm_lib_dir / name
if version != null then target_dir += "=" + version
if installed.has(target_dir) then
# Ignore packages installed in this run
return
end
installed.add target_dir
if target_dir.file_exists then
# Warn about packages previously installed,
# install dependencies anyway in case of a previous error.
print_error "Package '{name}' is already installed"
else
# Actually install it
var cmd_branch = ""
if version != null then cmd_branch = "--branch '{version}'"
var cmd = "git clone --depth 1 {cmd_branch} {git_repo.escape_to_sh} {target_dir.escape_to_sh}"
if verbose then print "+ {cmd}"
if "NIT_TESTING".environ == "true" then
# Silence git output when testing
cmd += " 2> /dev/null"
end
var proc = new Process("sh", "-c", cmd)
proc.wait
if proc.status != 0 then
print_error "Install of '{name}' failed"
exit 1
end
end
# Recursive install
var ini = new IniFile.from_file(target_dir/"package.ini")
var import_line = ini["package.import"]
if import_line != null then
install_packages import_line
end
end
src/nitpm.nit:159,2--203,4