Skip to content
This repository has been archived by the owner on Apr 15, 2020. It is now read-only.

Commit

Permalink
Use clone command directly for cloning
Browse files Browse the repository at this point in the history
  • Loading branch information
fakhrulhilal committed Apr 27, 2018
1 parent 916ddba commit 626929b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
18 changes: 5 additions & 13 deletions GitDownloader/GitDownloader.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Function Update-GitRepository {
If ($CurrentBranch -ine $BranchTag) {
Write-Host "Undoing any pending changes in $Path"
Invoke-VerboseCommand -Command {
git checkout "$BranchTag"
git checkout $BranchTag
git checkout -- .
git clean -fdx
}
Expand All @@ -98,10 +98,10 @@ Function Update-GitRepository {
# try to use token provided by TFS server
If (Test-SameTfsServer -Uri $Uri) {
$AuthHeader = "Authorization: bearer $($Env:SYSTEM_ACCESSTOKEN)"
Invoke-VerboseCommand -Command { git -c http.extraheader="$AuthHeader" pull origin "$BranchTag" }
Invoke-VerboseCommand -Command { git -c http.extraheader="$AuthHeader" pull origin $BranchTag }
}
Else {
Invoke-VerboseCommand -Command { git pull origin "$BranchTag" }
Invoke-VerboseCommand -Command { git pull origin $BranchTag }
}
}

Expand All @@ -113,25 +113,17 @@ Function Start-CloneGitRepository {
)

Write-Host "Cloning $Uri for branch/tag '$BranchTag' into $Path"
New-Item -Path $Path -ItemType Directory -Force | Out-Null
Set-Location -Path $Path | Out-Null
Invoke-VerboseCommand -Command {
git init "$Path"
git config credential.interactive never
git remote add origin "$Uri"
}
# try to embed authentication from system token for same TFS server
If ((Test-SameTfsServer -Uri $Uri)) {
$AuthHeader = "Authorization: bearer $($Env:SYSTEM_ACCESSTOKEN)"
Invoke-VerboseCommand -Command { git -c http.extraheader="$AuthHeader" fetch --progress --prune origin "$BranchTag" }
Invoke-VerboseCommand -Command { git -c http.extraheader="$AuthHeader" clone --single-branch --progress -b $BranchTag "$Uri" "$Path" }
}
Else {
Invoke-VerboseCommand -Command { git fetch --progress --prune origin "$BranchTag" }
Invoke-VerboseCommand -Command { git clone --single-branch --progress -b $BranchTag "$Uri" "$Path" }
}
If ($LastExitCode -ne 0) {
Write-Error $output -ErrorAction Stop
}
Invoke-VerboseCommand -Command { git checkout --progress --force "$BranchTag" }
}

Function Get-GitRepositoryUri {
Expand Down
2 changes: 1 addition & 1 deletion GitDownloader/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 0,
"Minor": 2,
"Patch": 8
"Patch": 11
},
"instanceNameFormat": "Fetch git: $(Repository)",
"groups": [
Expand Down
2 changes: 1 addition & 1 deletion vss-extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifestVersion": 1,
"id": "GitDownloader",
"name": "Git Repository Downloader",
"version": "0.2.8",
"version": "0.2.11",
"publisher": "fakhrulhilal-maktum",
"targets": [
{
Expand Down

0 comments on commit 626929b

Please sign in to comment.