Skip to content

Commit 613da74

Browse files
authored
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
1 parent 8c4fdae commit 613da74

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

src/fpm.f90

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module fpm
55
fpm_run_settings, fpm_install_settings, fpm_test_settings
66
use fpm_dependency, only : new_dependency_tree
77
use fpm_environment, only: run, get_env
8-
use fpm_filesystem, only: is_dir, join_path, number_of_rows, list_files, exists, basename
8+
use fpm_filesystem, only: is_dir, join_path, number_of_rows, list_files, exists, basename, filewrite, mkdir
99
use fpm_model, only: fpm_model_t, srcfile_t, show_model, &
1010
FPM_SCOPE_UNKNOWN, FPM_SCOPE_LIB, FPM_SCOPE_DEP, &
1111
FPM_SCOPE_APP, FPM_SCOPE_EXAMPLE, FPM_SCOPE_TEST
@@ -58,6 +58,11 @@ subroutine build_model(model, settings, package, error)
5858
call model%deps%add(package, error)
5959
if (allocated(error)) return
6060

61+
! build/ directory should now exist
62+
if (.not.exists("build/.gitignore")) then
63+
call filewrite(join_path("build", ".gitignore"),["*"])
64+
end if
65+
6166
if(settings%compiler.eq.'')then
6267
model%fortran_compiler = 'gfortran'
6368
else

src/fpm/cmd/new.f90

-3
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,6 @@ subroutine cmd_new(settings)
9898
! like realpath() or getcwd().
9999
bname=basename(settings%name)
100100

101-
! create NAME/.gitignore file
102-
call warnwrite(join_path(settings%name, '.gitignore'), ['build/*'])
103-
104101
littlefile=[character(len=80) :: '# '//bname, 'My cool new project!']
105102

106103
! create NAME/README.md

src/fpm/cmd/update.f90

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module fpm_cmd_update
22
use fpm_command_line, only : fpm_update_settings
33
use fpm_dependency, only : dependency_tree_t, new_dependency_tree
44
use fpm_error, only : error_t, fpm_stop
5-
use fpm_filesystem, only : exists, mkdir, join_path, delete_file
5+
use fpm_filesystem, only : exists, mkdir, join_path, delete_file, filewrite
66
use fpm_manifest, only : package_config_t, get_package_data
77
implicit none
88
private
@@ -26,6 +26,7 @@ subroutine cmd_update(settings)
2626

2727
if (.not.exists("build")) then
2828
call mkdir("build")
29+
call filewrite(join_path("build", ".gitignore"),["*"])
2930
end if
3031

3132
cache = join_path("build", "cache.toml")

src/fpm_command_line.f90

+2-5
Original file line numberDiff line numberDiff line change
@@ -938,14 +938,11 @@ subroutine set_help()
938938
' o runs the command "git init" in that directory ', &
939939
' o populates the directory with the default project directories ', &
940940
' o adds sample Fortran source files ', &
941-
' o adds a ".gitignore" file for ignoring the build/ directory ', &
942-
' (where fpm-generated output will be placed) ', &
943941
' ', &
944942
' The default file structure (that will be automatically scanned) is ', &
945943
' ', &
946944
' NAME/ ', &
947945
' fpm.toml ', &
948-
' .gitignore ', &
949946
' src/ ', &
950947
' NAME.f90 ', &
951948
' app/ ', &
@@ -1006,8 +1003,8 @@ subroutine set_help()
10061003
' depend extensively on non-default build options. ', &
10071004
' ', &
10081005
' --bare A minimal manifest file ("fpm.toml") is created and ', &
1009-
' a ".gitignore" and "README.md" file is created but no ', &
1010-
' directories or sample Fortran is generated. ', &
1006+
' "README.md" file is created but no directories or ', &
1007+
' sample Fortran are generated. ', &
10111008
' ', &
10121009
' --help print this help and exit ', &
10131010
' --version print program version information and exit ', &

0 commit comments

Comments
 (0)