Skip to content

Invoke SamplerGit

gaelcolas edited this page Jul 18, 2024 · 1 revision

Invoke-SamplerGit

SYNOPSIS

Executes git with the provided arguments.

SYNTAX

Invoke-SamplerGit [-Argument] <String[]> [<CommonParameters>]

DESCRIPTION

This command executes git with the provided arguments and throws an error if the call failed.

EXAMPLES

EXAMPLE 1

Invoke-SamplerGit -Argument @('config', 'user.name', 'MyName')

Calls git to set user name in the git config.

PARAMETERS

-Argument

Specifies the arguments to call git with. It is passes as an array of strings, e.g. @('tag', 'v2.0.0').

Type: String[]
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

NOTES

Git does not throw an error that can be caught by the pipeline. For example this git command error but does not throw 'hello' as one would expect.

PS> try { git describe --contains } catch { throw 'hello' }
fatal: cannot describe '144e0422398e89cc8451ebba738c0a410b628302'

So we have to determine if git worked or not by checking the last exit code and then throw an error to stop the pipeline.

RELATED LINKS

Clone this wiki locally