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 <dstolee@microsoft.com>
This commit is contained in:
Derrick Stolee 2021-04-29 11:18:46 -04:00 коммит произвёл Johannes Schindelin
Родитель f3ef0b86ff
Коммит 810b7d9c74
1 изменённых файлов: 32 добавлений и 0 удалений

Просмотреть файл

@ -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)
{