Skip to content

Commit 13083cf

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 a2e5c8d commit 13083cf

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

builtin/update-microsoft-git.c

+30
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,36 @@ 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+
strvec_pushl(&args, "brew", "update", NULL);
39+
res = run_command_v_opt(args.v, RUN_GIT_CMD);
40+
strvec_clear(&args);
41+
42+
if (!res) {
43+
error(_("'brew update' failed; is brew installed?"));
44+
return 1;
45+
}
46+
47+
strvec_pushl(&args, "brew", "upgrade", "--cask", "microsoft-git", NULL);
48+
res = run_command_v_opt(args.v, RUN_GIT_CMD);
49+
strvec_clear(&args);
50+
51+
return res;
52+
}
2353
#else
2454
static int platform_specific_upgrade(void)
2555
{

0 commit comments

Comments
 (0)