Skip to content

Commit b358326

Browse files
authored
Merge pull request #45 from mjcheetham/unlink-javagcm
Unlink the Java GCM from Homebrew if installed
2 parents 0acd9bb + a001d1c commit b358326

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ Basic HTTP authentication support|✓|✓|✓
4343

4444
To use GCM Core, you can download the [latest installer](https://github.com/Microsoft/Git-Credential-Manager-Core/releases/latest) for your platform. To install, double-click installation package and follow the instructions presented.
4545

46+
### Git Credential Manager for Mac and Linux (Java-based GCM)
47+
48+
If you have an existing installation of the 'Java GCM' on macOS and you have installed this using Homebrew, this installation will be unlinked (`brew unlink git-credential-manager`) when GCM Core is installed. Additionally any symlinks or files previously located at `/usr/local/bin/git-credential-manager` will be replaced with a GCM Core symlink.
49+
4650
## How to use
4751

4852
You don't! GCM gets called when Git needs credentials for an operation. For example, when pushing (`git push`) to [Azure DevOps](https://dev.azure.com), it automatically opens a window and initializes an OAuth2 flow to get your personal access token.

src/osx/Installer.Mac/scripts/postinstall

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,31 @@
11
#!/bin/bash
22
set -e
33

4-
# Make symlink to GCM in /usr/local/bin
5-
if [ ! -e /usr/local/bin/git-credential-manager ]
4+
function IsBrewPkgInstalled
5+
{
6+
# Check if Homebrew is installed
7+
/usr/bin/which brew > /dev/null
8+
if [ $? -eq 0 ]
9+
then
10+
# Check if the package has been installed
11+
brew ls --versions $1 > /dev/null
12+
if [ $? -eq 0 ]
13+
then
14+
return 0
15+
fi
16+
fi
17+
return 1
18+
}
19+
20+
# Check if Java GCM is present on this system and unlink it should it exist
21+
if [ -L /usr/local/bin/git-credential-manager && IsBrewPkgInstalled "git-credential-manager" ]
622
then
7-
/bin/ln -s /usr/local/share/gcm-core/git-credential-manager /usr/local/bin/git-credential-manager
23+
brew unlink git-credential-manager
824
fi
925

26+
# Create symlink to GCM in /usr/local/bin
27+
/bin/ln -Fs /usr/local/share/gcm-core/git-credential-manager /usr/local/bin/git-credential-manager
28+
1029
# Set system gitconfig for the current user
1130
USER_ID=`id -u "${USER}"`
1231
if [ "${COMMAND_LINE_INSTALL}" = "" ]

0 commit comments

Comments
 (0)