1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

v init: create a .gitignore in existing git repo if it does not exist yet (#10488)

This commit is contained in:
Ryan Roden-Corrent
2021-06-19 14:36:12 -04:00
committed by GitHub
parent 123682dffb
commit f0ad0b024e
2 changed files with 48 additions and 16 deletions

View File

@ -2,15 +2,7 @@ import os
const test_path = 'vcreate_test'
fn test_v_init() ? {
dir := os.join_path(os.temp_dir(), test_path)
os.rmdir_all(dir) or {}
os.mkdir(dir) ?
defer {
os.rmdir_all(dir) or {}
}
os.chdir(dir)
fn init_and_check() ? {
vexe := os.getenv('VEXE')
os.execute_or_panic('$vexe init')
@ -45,3 +37,43 @@ fn test_v_init() ? {
'',
].join('\n')
}
fn test_v_init() ? {
dir := os.join_path(os.temp_dir(), test_path)
os.rmdir_all(dir) or {}
os.mkdir(dir) ?
defer {
os.rmdir_all(dir) or {}
}
os.chdir(dir)
init_and_check() ?
}
fn test_v_init_in_git_dir() ? {
dir := os.join_path(os.temp_dir(), test_path)
os.rmdir_all(dir) or {}
os.execute_or_panic('git init $dir')
defer {
os.rmdir_all(dir) or {}
}
os.chdir(dir)
init_and_check() ?
}
fn test_v_init_no_overwrite_gitignore() ? {
dir := os.join_path(os.temp_dir(), test_path)
os.rmdir_all(dir) or {}
os.mkdir(dir) or {}
os.write_file('$dir/.gitignore', 'blah') ?
defer {
os.rmdir_all(dir) or {}
}
os.chdir(dir)
vexe := os.getenv('VEXE')
os.execute_or_panic('$vexe init')
assert os.read_file('.gitignore') ? == 'blah'
}