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 <dstolee@microsoft.com>
  • Loading branch information
derrickstolee authored and dscho committed Aug 21, 2023
1 parent 8ba7557 commit ddba2fa
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions builtin/update-microsoft-git.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,38 @@ static int platform_specific_upgrade(void)
strvec_push(&cp.args, "git-update-git-for-windows");
return run_command(&cp);
}
#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 child_process update = CHILD_PROCESS_INIT;
struct child_process upgrade = CHILD_PROCESS_INIT;

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

strvec_pushl(&update.args, "brew", "update", NULL);
res = run_command(&update);

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

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

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

0 comments on commit ddba2fa

Please sign in to comment.