From 78628da995e92c2cc371de65a90142f8a91b62bf Mon Sep 17 00:00:00 2001 From: Robert Iannucci Date: Mon, 24 Apr 2017 18:21:39 -0700 Subject: [PATCH] [cipd.ps1] catch CommandNotFoundException if git is not available yet R=brucedawson@chromium.org Bug: 714920 Change-Id: I6a0ea81e1d87fa2604e9f614a89ff48619cbffd0 Reviewed-on: https://chromium-review.googlesource.com/486085 Commit-Queue: Robbie Iannucci Reviewed-by: Vadim Shtayura --- cipd.ps1 | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cipd.ps1 b/cipd.ps1 index 32ec2b461..973af4f1f 100644 --- a/cipd.ps1 +++ b/cipd.ps1 @@ -28,11 +28,15 @@ if ([environment]::Is64BitOperatingSystem) { $url = "$cipdClientSrv/client?platform=$plat-$arch&version=$cipdClientVer" $client = Join-Path $myPath -ChildPath ".cipd_client.exe" -$depot_tools_version = &git -C $myPath rev-parse HEAD 2>&1 -if ($LastExitCode -eq 0) { - $user_agent = "depot_tools/$depot_tools_version" -} else { - $user_agent = "depot_tools/???" +try { + $depot_tools_version = &git -C $myPath rev-parse HEAD 2>&1 + if ($LastExitCode -eq 0) { + $user_agent = "depot_tools/$depot_tools_version" + } else { + $user_agent = "depot_tools/???" + } +} catch [System.Management.Automation.CommandNotFoundException] { + $user_agent = "depot_tools/no_git/???" } $Env:CIPD_HTTP_USER_AGENT_PREFIX = $user_agent