Skip to content

Commit e1284eb

Browse files
committed
update-microsoft-git: use brew on macOS
The steps to update the microsoft-git cask are: 1. brew update 2. brew upgrade --cask microsoft-git This is adapted from the UpgradeVerb within microsoft/scalar. There is one important simplification: Scalar needed to check 'brew list --cask' to find out if the 'scalar' cask or the 'scalar-azrepos' cask was installed (which determined if the 'microsoft-git' cask was a necessary dependency). We do not need that here, since we are already in the microsoft-git cask. Signed-off-by: Derrick Stolee <[email protected]>
1 parent c301c97 commit e1284eb

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

builtin/update-microsoft-git.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,39 @@ static int platform_specific_upgrade(void)
2020
strvec_clear(&args);
2121
return res;
2222
}
23+
#elif defined(__APPLE__)
24+
/*
25+
* On macOS, we expect the user to have the microsoft-git
26+
* cask installed via Homebrew. We check using these
27+
* commands:
28+
*
29+
* 1. 'brew update' to get latest versions.
30+
* 2. 'brew upgrade --cask microsoft-git' to get the
31+
* latest version.
32+
*/
33+
static int platform_specific_upgrade(void)
34+
{
35+
int res;
36+
struct strvec args = STRVEC_INIT;
37+
38+
printf("Updating Homebrew with 'brew update'\n");
39+
40+
strvec_pushl(&args, "brew", "update", NULL);
41+
res = run_command_v_opt(args.v, 0);
42+
strvec_clear(&args);
43+
44+
if (res) {
45+
error(_("'brew update' failed; is brew installed?"));
46+
return 1;
47+
}
48+
49+
printf("Upgrading microsoft-git with 'brew upgrade --cask microsoft-git'\n");
50+
strvec_pushl(&args, "brew", "upgrade", "--cask", "microsoft-git", NULL);
51+
res = run_command_v_opt(args.v, 0);
52+
strvec_clear(&args);
53+
54+
return res;
55+
}
2356
#else
2457
static int platform_specific_upgrade(void)
2558
{

0 commit comments

Comments
 (0)