Skip to content

Commit

Permalink
update-microsoft-git: use brew on macOS
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
derrickstolee authored and dscho committed Jun 7, 2021
1 parent ca0e0bf commit 14c9bd1
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions builtin/update-microsoft-git.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,39 @@ static int platform_specific_upgrade(void)
strvec_clear(&args);
return res;
}
#elif defined(__APPLE__)
/*
* On macOS, we expect the user to have the microsoft-git
* cask installed via Homebrew. We check using these
* commands:
*
* 1. 'brew update' to get latest versions.
* 2. 'brew upgrade --cask microsoft-git' to get the
* latest version.
*/
static int platform_specific_upgrade(void)
{
int res;
struct strvec args = STRVEC_INIT;

printf("Updating Homebrew with 'brew update'\n");

strvec_pushl(&args, "brew", "update", NULL);
res = run_command_v_opt(args.v, 0);
strvec_clear(&args);

if (res) {
error(_("'brew update' failed; is brew installed?"));
return 1;
}

printf("Upgrading microsoft-git with 'brew upgrade --cask microsoft-git'\n");
strvec_pushl(&args, "brew", "upgrade", "--cask", "microsoft-git", NULL);
res = run_command_v_opt(args.v, 0);
strvec_clear(&args);

return res;
}
#else
static int platform_specific_upgrade(void)
{
Expand Down

0 comments on commit 14c9bd1

Please sign in to comment.