Ignore:
Timestamp:
Jan 15, 2025, 1:42:03 PM (8 days ago)
Author:
jbclement
Message:

COMMON:
Follow-up of r3576:

  • Status result is added to the file "version_stat-diff.txt", previously called "version_diff.txt";
  • Addition of the functionnality for the program 'Reshape' dedicated to the PEM;
  • Improvements of the visualization format.

JBC

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.COMMON/makelmdz_fcm

    r3576 r3578  
    603603
    604604# Path and name of the file containing the difference result
    605 diff_file="version_diff.txt"
     605res_file="version_stat-diff.txt"
    606606
    607607# Get the current date
     
    611611vcs_info=""
    612612vcs_diff=""
     613vcs_status=""
    613614for dir in "$LMDGCM/.."/*; do
    614615    # Skip if it is not a directory or the name contains "git" or "svn"
     
    618619    # Determine the version control system for each subdirectory
    619620    if command -v svn > /dev/null && svn info "$dir" > /dev/null 2>&1; then # SVN
    620         vcs_info+="\n=== SVN Information for $dir ===\n$(svn info "$dir")\n"
    621         vcs_diff+="\n=== SVN Diff for $dir ===\n$(svn diff "$dir")\n"
     621        vcs_info+="\n=== SVN Information for $(basename "$dir") ===\n$(svn info "$dir")\n"
     622        vcs_diff+="\n=== SVN Diff for $(basename "$dir") ===\n$(svn diff "$dir")\n"
     623        vcs_status+="\n=== SVN Status for $(basename "$dir") ===\n$(svn status "$dir")\n"
    622624    elif command -v git > /dev/null && git -C "$dir" rev-parse --is-inside-work-tree > /dev/null 2>&1; then # Git
    623         vcs_info+="\n=== Git Information for $dir ===\n$(git -C "$dir" log -1 --pretty=format:"%H%n%an%n%ad%n%s")\n"
    624         vcs_diff+="\n=== Git Diff for $dir ===\n$(git -C "$dir" diff)\n"
     625        vcs_info+="=== Git Information for $(basename "$dir") ===\n$(git -C "$dir" log -1 --pretty=format:"%H%n%an%n%ad%n%s")\n"
     626        vcs_diff+="\n=== Git Diff for $(basename "$dir") ===\n$(git -C "$dir" diff)\n"
     627        vcs_status+="\n=== Git Status for $(basename "$dir") ===\n$(git -C "$dir" status --short)\n"
    625628    else # None
    626         vcs_info+="\n=== No version control system for $dir ===\n"
     629        vcs_info+="\n=== No version control system for $(basename "$dir") ===\n"
    627630    fi
    628631done
     
    635638! DESCRIPTION:
    636639!    The subroutine 'print_version_info' prints compilation details, the
    637 !    version control information (SVN or Git) and the diff result if
    638 !    applicable.
     640!    version control information (SVN or Git), the status and the diff
     641!    result if applicable.
    639642!
    640643! PARAMETERS:
     
    655658SUBROUTINE print_version_info()
    656659
    657     write(*,'(A)') '======= Compilation details ======='
    658     write(*,'(A)') 'Date: ${current_date}'
    659     write(*,'(A)') 'Command: ${compilation_command}'
    660     write(*,*)
     660write(*,'(a)') '======= Compilation details ======='
     661write(*,'(a)') '> Date: ${current_date}'
     662write(*,'(a)') '> Command: ${compilation_command}'
     663write(*,*)
    661664EOF
    662665
    663666if [ -n "$vcs_info" ]; then
    664     echo "    write(*,'(A)') '=== Version Control Information ==='" >> "$info_file"
     667    echo "write(*,'(a)') '=== Version Control Information ==='" >> "$info_file"
    665668    while IFS= read -r line; do
    666         echo "    write(*,'(A)') '${line//\'/\'\'}'" >> "$info_file"
     669        echo "write(*,'(a)') '${line//\'/\'\'}'" >> "$info_file"
    667670    done <<< "$(echo -e "$vcs_info")"
     671else
     672    echo "write(*,'(a)') '=== No version control system ==='" >> "$info_file"
     673fi
     674
     675if [ -n "$vcs_status" ]; then
     676    echo "write(*,*)" >> "$info_file"
     677    echo "write(*,'(a)') '=== Version Control Status ==='" >> "$info_file"
     678    echo "write(*,'(a)') '> Writing status result to the file \"${res_file}\".'" >> "$info_file"
     679    echo "open(unit = 1, file = \"${res_file}\",status = 'replace',action = 'write')" >> "$info_file"
     680    while IFS= read -r line; do
     681        echo "write(1,'(a)') '${line//\'/\'\'}'" >> "$info_file"
     682    done <<< "$(echo -e "$vcs_status")"
     683    echo "close(1)" >> "$info_file"
    668684fi
    669685
    670686if [ -n "$vcs_diff" ]; then
    671     echo "    write(*,*)" >> "$info_file"
    672     echo "    write(*,'(A)') '====== Version Control Diff ======='" >> "$info_file"
    673     echo "    write(*,'(A)') 'Writing diff to file: ${diff_file}'" >> "$info_file"
    674     echo "    open(unit = 1, file = \"${diff_file}\", status = 'replace', action = 'write')" >> "$info_file"
     687    echo "write(*,*)" >> "$info_file"
     688    echo "write(*,'(a)') '====== Version Control Diff ======='" >> "$info_file"
     689    echo "write(*,'(a)') '> Writing diff result to the file \"${res_file}\".'" >> "$info_file"
     690    echo "open(unit = 1, file = \"${res_file}\",status = 'unknown',position = 'append',action = 'write')" >> "$info_file"
    675691    while IFS= read -r line; do
    676         echo "    write(1,'(A)') '${line//\'/\'\'}'" >> "$info_file"
     692        echo "write(1,'(a)') '${line//\'/\'\'}'" >> "$info_file"
    677693    done <<< "$(echo -e "$vcs_diff")"
    678     echo "    close(1)" >> "$info_file"
     694    echo "close(1)" >> "$info_file"
    679695fi
    680696
    681697cat << EOF >> "$info_file"
    682     write(*,'(A)') '==================================='
     698write(*,'(a)') '==================================='
    683699
    684700END SUBROUTINE print_version_info
     
    688704
    689705# Termination message
    690 echo "'$info_file' has been successfully generated."
     706echo "'$info_file' has been generated successfully."
    691707
    692708
Note: See TracChangeset for help on using the changeset viewer.