Skip to content

Commit aef1761

Browse files
derrickstoleedscho
authored andcommitted
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 edba6af commit aef1761

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

builtin/update-microsoft-git.c

+32
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,38 @@ static int platform_specific_upgrade(void)
1717
strvec_push(&cp.args, "git-update-git-for-windows");
1818
return run_command(&cp);
1919
}
20+
#elif defined(__APPLE__)
21+
/*
22+
* On macOS, we expect the user to have the microsoft-git
23+
* cask installed via Homebrew. We check using these
24+
* commands:
25+
*
26+
* 1. 'brew update' to get latest versions.
27+
* 2. 'brew upgrade --cask microsoft-git' to get the
28+
* latest version.
29+
*/
30+
static int platform_specific_upgrade(void)
31+
{
32+
int res;
33+
struct child_process update = CHILD_PROCESS_INIT;
34+
struct child_process upgrade = CHILD_PROCESS_INIT;
35+
36+
printf("Updating Homebrew with 'brew update'\n");
37+
38+
strvec_pushl(&update.args, "brew", "update", NULL);
39+
res = run_command(&update);
40+
41+
if (res) {
42+
error(_("'brew update' failed; is brew installed?"));
43+
return 1;
44+
}
45+
46+
printf("Upgrading microsoft-git with 'brew upgrade --cask microsoft-git'\n");
47+
strvec_pushl(&upgrade.args, "brew", "upgrade", "--cask", "microsoft-git", NULL);
48+
res = run_command(&upgrade);
49+
50+
return res;
51+
}
2052
#else
2153
static int platform_specific_upgrade(void)
2254
{

0 commit comments

Comments
 (0)