@@ -575,6 +575,48 @@ subroutine cmd_new(settings)
575
575
call run(' git init ' // settings% name)
576
576
contains
577
577
578
+ function default_user (what ) result(user)
579
+ implicit none
580
+ character (len= 5 ), intent (in ) :: what
581
+ character (len= :), allocatable :: user
582
+ if (what==" uname" ) then
583
+ user = " Jane Doe"
584
+ else
585
+
586
+ end if
587
+ return
588
+ end function default_user
589
+
590
+ function git_user (what ) result(user)
591
+ use fpm_filesystem, only : get_temp_filename, getline
592
+ implicit none
593
+ character (len= 5 ), intent (in ) :: what
594
+ character (len= :), allocatable :: user
595
+ character (len= :), allocatable :: temp_user, iomsg
596
+ integer :: stat, unit
597
+ allocate (temp_user, source= get_temp_filename())
598
+ if (what==" uname" ) then
599
+ user = " git config --get user.name > " // temp_user
600
+ else
601
+ user = " git config --get user.email > " // temp_user
602
+ end if
603
+ call execute_command_line(user, exitstat= stat)
604
+ if (stat /= 0 ) then
605
+ user = default_user(what)
606
+ return
607
+ end if
608
+ open (file= temp_user, newunit= unit)
609
+ call getline(unit, user, stat, iomsg)
610
+ if (stat /= 0 ) then
611
+ user = default_user(what)
612
+ end if
613
+ close (unit, status= " delete" )
614
+ if (len (user)==0 ) then
615
+ user = default_user(what)
616
+ end if
617
+ return
618
+ end function git_user
619
+
578
620
subroutine create_verified_basic_manifest (filename )
579
621
! > create a basic but verified default manifest file
580
622
use fpm_toml, only : toml_table, toml_serializer, set_value
@@ -603,9 +645,9 @@ subroutine create_verified_basic_manifest(filename)
603
645
call set_value(table, " name" , BNAME)
604
646
call set_value(table, " version" , " 0.1.0" )
605
647
call set_value(table, " license" , " license" )
606
- call set_value(table, " author" , " Jane Doe " )
607
- call set_value(table,
" maintainer" ,
" [email protected] " )
608
- call set_value(table, " copyright" , ' Copyright ' // date(1 :4 )// ' , Jane Doe ' )
648
+ call set_value(table, " author" , git_user( " uname " ) )
649
+ call set_value(table, " maintainer" , git_user( " email " ) )
650
+ call set_value(table, " copyright" , ' Copyright ' // date(1 :4 )// ' , ' // git_user( " uname " ) )
609
651
! continue building of manifest
610
652
! ...
611
653
call new_package(package, table, error= error)
0 commit comments