get_git_hash Function

function get_git_hash(length_in)

Returns the git hash of the current commit

Arguments

Type IntentOptional Attributes Name
integer, intent(in), optional :: length_in

How many characters of the hash to return, default is 7

Return Value character(len=:), allocatable


Contents

Source Code


Source Code

function get_git_hash(length_in)
  implicit none
  !> How many characters of the hash to return, default is 7
  integer, optional, intent(in) :: length_in
  integer :: length
  character(:), allocatable :: get_git_hash

  length = 7
  if (present(length_in)) then
    if (length_in <= 40) then
      length = length_in
    end if
  end if

  allocate(character(length)::get_git_hash)
  get_git_hash = GIT_HASH(1:length)
end function get_git_hash