Git.ps1

<#
    .SYNOPSIS
        Open current projet url.
    .DESCRIPTION
        Open the current project url with the default browser
         
    .LINK
        Nexus Innovations : http://www.nexusinno.com
    --------------------------------------------------------------------------------------
    Module 'Nexus.PSToolkit'
    by: Nexus Innovations.
    --------------------------------------------------------------------------------------
#>

function global:Open-CurrentGitUrl()
{
    Start-Process -FilePath (git config --get remote.origin.url);
}

<#
    .SYNOPSIS
 
    .DESCRIPTION
 
    .LINK
        Nexus Innovations : http://www.nexusinno.com
    --------------------------------------------------------------------------------------
    Module 'Nexus.PSToolkit'
    by: Nexus Innovations.
    --------------------------------------------------------------------------------------
#>

function global:Clone-ClientRepository {
    Param (
        [Parameter(Mandatory=$false)]
        [string]$UserName,

        [Parameter(Mandatory=$false)]
        [string]$Password,

        [Parameter(Mandatory=$true)]
        [ValidatePattern("https:\/\/nexusinno\.visualstudio\.com\/_git")]
        [string]$VSTSClientRepoUrl,

        [Parameter(Mandatory=$false)]
        [string]$DestinationPath,

        [switch] $UseDevelopBranch
    )

    # To specified the branch name to clone
    if ($UseDevelopBranch) {
        $branchName = "develop"
    } else {
        $branchName = "master"
    }

    # Params UserName & Password or there for the case where the user will need to
    # access to private repo. This consideration have to be implemented later!--Simon
    if ([string]::IsNullOrEmpty($DestinationPath)) {
        # -q is there to mask the error message
        git clone -b $branchName $VSTSClientRepoUrl -q
    } else {
        Set-Location $DestinationPath
        # -q is there to mask the error message
        git clone -b $branchName $VSTSClientRepoUrl -q
    }

    #return the folder path
    $subFolderName = $VSTSClientRepoUrl.Split('/') | Select-Object -Last 1
    $folderpath = Join-Path -Path (Get-Location) -ChildPath  $subFolderName
    
    return $folderpath
}