fpm_git Module

Implementation for interacting with git repositories.



Variables

Type Visibility Attributes Name Initial
character(len=*), public, parameter :: compressed_package_name = 'compressed_package'

Name of the compressed package that is generated temporarily.

type(enum_descriptor), public, parameter :: git_descriptor = enum_descriptor()

Actual enumerator for descriptors

character(len=*), public, parameter :: out_fmt = '("#", *(1x, g0))'

Common output format for writing to the command line


Derived Types

type, public ::  enum_descriptor

Possible git target

Components

Type Visibility Attributes Name Initial
integer, public :: branch = 201

Branch in git repository

integer, public :: default = 200

Default target

integer, public :: error = -999

Invalid descriptor

integer, public :: revision = 203

Commit hash

integer, public :: tag = 202

Tag in git repository

type, public, extends(serializable_t) ::  git_target_t

Description of an git target

Components

Type Visibility Attributes Name Initial
integer, public :: descriptor = git_descriptor%default

Kind of the git target

character(len=:), public, allocatable :: object

Additional descriptor of the git object

character(len=:), public, allocatable :: url

Target URL of the git repository

Type-Bound Procedures

procedure, public :: checkout ../../

Fetch and checkout in local directory

generic, public :: dump => dump_to_toml, dump_to_file, dump_to_unit
procedure, public :: dump_to_toml
procedure, public :: info ../../

Show information on instance

generic, public :: load => load_from_toml, load_from_file, load_from_unit
procedure, public :: load_from_toml
generic, public :: operator(==) => serializable_is_same
procedure, public :: serializable_is_same => git_is_same ../../

Serialization interface

procedure, public, non_overridable :: test_serialization ../../

Test load/write roundtrip


Functions

public pure function descriptor_name(descriptor) result(name)

Code git descriptor to a string

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: descriptor

Return Value character(len=:), allocatable

public function git_is_same(this, that)

Check that two git targets are equal All checks passed!

Arguments

Type IntentOptional Attributes Name
class(git_target_t), intent(in) :: this
class(serializable_t), intent(in) :: that

Return Value logical

public function git_matches_manifest(cached, manifest, verbosity, iunit)

Check that a cached dependency matches a manifest request

Read more…

Arguments

Type IntentOptional Attributes Name
type(git_target_t), intent(in) :: cached

Two input git targets

type(git_target_t), intent(in) :: manifest

Two input git targets

integer, intent(in) :: verbosity
integer, intent(in) :: iunit

Return Value logical

public function git_target_branch(url, branch) result(self)

Target a branch in the git repository

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: url

Target URL of the git repository

character(len=*), intent(in) :: branch

Name of the branch of interest

Return Value type(git_target_t)

New git target

public function git_target_default(url) result(self)

Default target

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: url

Target URL of the git repository

Return Value type(git_target_t)

New git target

public function git_target_revision(url, sha1) result(self)

Target a specific git revision

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: url

Target URL of the git repository

character(len=*), intent(in) :: sha1

Commit hash of interest

Return Value type(git_target_t)

New git target

public function git_target_tag(url, tag) result(self)

Target a git tag

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: url

Target URL of the git repository

character(len=*), intent(in) :: tag

Tag name of interest

Return Value type(git_target_t)

New git target

public pure function parse_descriptor(name)

Parse git descriptor identifier from a string

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: name

Return Value integer


Subroutines

public subroutine checkout(self, local_path, error)

Arguments

Type IntentOptional Attributes Name
class(git_target_t), intent(in) :: self

Instance of the git target

character(len=*), intent(in) :: local_path

Local path to checkout in

type(error_t), intent(out), allocatable :: error

Error

public subroutine dump_to_toml(self, table, error)

Dump dependency to toml table

Arguments

Type IntentOptional Attributes Name
class(git_target_t), intent(inout) :: self

Instance of the serializable object

type(toml_table), intent(inout) :: table

Data structure

type(error_t), intent(out), allocatable :: error

Error handling

public subroutine git_archive(source, destination, ref, additional_files, verbose, error)

Archive a folder using git archive.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: source

Directory to archive.

character(len=*), intent(in) :: destination

Destination of the archive.

character(len=*), intent(in) :: ref

(Symbolic) Reference to be archived.

character(len=*), intent(in), optional :: additional_files(:)

(Optional) list of additional untracked files to be added to the archive.

logical, intent(in) :: verbose

Print additional information if true.

type(error_t), intent(out), allocatable :: error

Error handling.

public subroutine git_revision(local_path, object, error)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: local_path

Local path to checkout in

character(len=:), intent(out), allocatable :: object

Git object reference

type(error_t), intent(out), allocatable :: error

Error

public subroutine info(self, unit, verbosity)

Show information on git target

Arguments

Type IntentOptional Attributes Name
class(git_target_t), intent(in) :: self

Instance of the git target

integer, intent(in) :: unit

Unit for IO

integer, intent(in), optional :: verbosity

Verbosity of the printout

public subroutine load_from_toml(self, table, error)

Read dependency from toml table (no checks made at this stage)

Read more…

Arguments

Type IntentOptional Attributes Name
class(git_target_t), intent(inout) :: self

Instance of the serializable object

type(toml_table), intent(inout) :: table

Data structure

type(error_t), intent(out), allocatable :: error

Error handling