param(
    [string]$repositoryName,
    [string]$publishPath
)

# Check if directory is part of Git repository
Set-Location -Path $publishPath
$isInsideWorkTree = git rev-parse --is-inside-work-tree
if ($isInsideWorkTree -eq "true") {
    # Use format: {COMMIT_DATE}.{REPOSITORY_NAME}.{BRANCH_NAME}+{COMMIT_ID}
    $date = git show -s --format=%cs HEAD
    $branchName = git rev-parse --abbrev-ref HEAD
    $commitId = git rev-parse --short HEAD
    Write-Host "$date.$repositoryName.$branchName+$commitId"
    exit 0
} else {
    # Use format: {CURRENT_DATE}.{REPOSITORY_NAME}
    $date = Get-Date -Format "yyyy-MM-dd"
    Write-Host "$date.$repositoryName"
    exit 0
}

exit 1