From 613da74f29b8ba8ca8de89bf403ab84e1490af30 Mon Sep 17 00:00:00 2001 From: urbanjost Date: Wed, 4 Aug 2021 15:27:03 -0400 Subject: Generate build/.gitignore (#528) - git-specific, but not git-dependent but is it better if managed directly by fpm - no .gitignore generated by subcommand new --- src/fpm.f90 | 7 ++++++- src/fpm/cmd/new.f90 | 3 --- src/fpm/cmd/update.f90 | 3 ++- src/fpm_command_line.f90 | 7 ++----- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/fpm.f90 b/src/fpm.f90 index 89eca1a..68e2bbd 100644 --- a/src/fpm.f90 +++ b/src/fpm.f90 @@ -5,7 +5,7 @@ use fpm_command_line, only: fpm_build_settings, fpm_new_settings, & fpm_run_settings, fpm_install_settings, fpm_test_settings use fpm_dependency, only : new_dependency_tree use fpm_environment, only: run, get_env -use fpm_filesystem, only: is_dir, join_path, number_of_rows, list_files, exists, basename +use fpm_filesystem, only: is_dir, join_path, number_of_rows, list_files, exists, basename, filewrite, mkdir use fpm_model, only: fpm_model_t, srcfile_t, show_model, & FPM_SCOPE_UNKNOWN, FPM_SCOPE_LIB, FPM_SCOPE_DEP, & FPM_SCOPE_APP, FPM_SCOPE_EXAMPLE, FPM_SCOPE_TEST @@ -58,6 +58,11 @@ subroutine build_model(model, settings, package, error) call model%deps%add(package, error) if (allocated(error)) return + ! build/ directory should now exist + if (.not.exists("build/.gitignore")) then + call filewrite(join_path("build", ".gitignore"),["*"]) + end if + if(settings%compiler.eq.'')then model%fortran_compiler = 'gfortran' else diff --git a/src/fpm/cmd/new.f90 b/src/fpm/cmd/new.f90 index 81cf62f..0afe651 100644 --- a/src/fpm/cmd/new.f90 +++ b/src/fpm/cmd/new.f90 @@ -98,9 +98,6 @@ character(len=:,kind=tfc),allocatable :: littlefile(:) ! like realpath() or getcwd(). bname=basename(settings%name) - ! create NAME/.gitignore file - call warnwrite(join_path(settings%name, '.gitignore'), ['build/*']) - littlefile=[character(len=80) :: '# '//bname, 'My cool new project!'] ! create NAME/README.md diff --git a/src/fpm/cmd/update.f90 b/src/fpm/cmd/update.f90 index aa99ca3..a9918bf 100644 --- a/src/fpm/cmd/update.f90 +++ b/src/fpm/cmd/update.f90 @@ -2,7 +2,7 @@ module fpm_cmd_update use fpm_command_line, only : fpm_update_settings use fpm_dependency, only : dependency_tree_t, new_dependency_tree use fpm_error, only : error_t, fpm_stop - use fpm_filesystem, only : exists, mkdir, join_path, delete_file + use fpm_filesystem, only : exists, mkdir, join_path, delete_file, filewrite use fpm_manifest, only : package_config_t, get_package_data implicit none private @@ -26,6 +26,7 @@ contains if (.not.exists("build")) then call mkdir("build") + call filewrite(join_path("build", ".gitignore"),["*"]) end if cache = join_path("build", "cache.toml") diff --git a/src/fpm_command_line.f90 b/src/fpm_command_line.f90 index 86e6d5d..959a13f 100644 --- a/src/fpm_command_line.f90 +++ b/src/fpm_command_line.f90 @@ -938,14 +938,11 @@ contains ' o runs the command "git init" in that directory ', & ' o populates the directory with the default project directories ', & ' o adds sample Fortran source files ', & - ' o adds a ".gitignore" file for ignoring the build/ directory ', & - ' (where fpm-generated output will be placed) ', & ' ', & ' The default file structure (that will be automatically scanned) is ', & ' ', & ' NAME/ ', & ' fpm.toml ', & - ' .gitignore ', & ' src/ ', & ' NAME.f90 ', & ' app/ ', & @@ -1006,8 +1003,8 @@ contains ' depend extensively on non-default build options. ', & ' ', & ' --bare A minimal manifest file ("fpm.toml") is created and ', & - ' a ".gitignore" and "README.md" file is created but no ', & - ' directories or sample Fortran is generated. ', & + ' "README.md" file is created but no directories or ', & + ' sample Fortran are generated. ', & ' ', & ' --help print this help and exit ', & ' --version print program version information and exit ', & -- cgit v1.2.3