Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Git Credential Manager Core as a credential helper option #294

Merged
merged 4 commits into from
Jun 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ edit-git-bash.exe
/mingw-w64-git-credential-manager/*.src.tar.gz
/mingw-w64-git-credential-manager/gcmw-*.zip
/mingw-w64-git-credential-manager/v[1-9]*.zip
/mingw-w64-git-credential-manager-core/pkg/
/mingw-w64-git-credential-manager-core/src/
/mingw-w64-git-credential-manager-core/*.pkg.tar.*
/mingw-w64-git-credential-manager-core/*.src.tar.gz
/mingw-w64-git-credential-manager-core/gcmcore-*.zip
/mingw-w64-git-credential-manager-core/v[1-9]*.zip
/mingw-w64-wintoast/mingw-w64-*-wintoast-*-any.pkg.tar.xz
/mingw-w64-wintoast/pkg
/mingw-w64-wintoast/src
Expand Down
2 changes: 1 addition & 1 deletion get-sources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ do
then

case "$name" in
git-extra|mingw-w64-x86_64-git|mingw-w64-i686-git|msys2-runtime|mingw-w64-x86_64-git-credential-manager|mingw-w64-i686-git-credential-manager|mingw-w64-i686-git-lfs|mingw-w64-x86_64-git-lfs|curl|mingw-w64-i686-curl|mingw-w64-x86_64-curl|mingw-w64-i686-wintoast|mingw-w64-x86_64-wintoast|bash|heimdal|perl|openssh)
git-extra|mingw-w64-x86_64-git|mingw-w64-i686-git|msys2-runtime|mingw-w64-x86_64-git-credential-manager|mingw-w64-i686-git-credential-manager|mingw-w64-x86_64-git-credential-manager-core|mingw-w64-i686-git-credential-manager-core|mingw-w64-i686-git-lfs|mingw-w64-x86_64-git-lfs|curl|mingw-w64-i686-curl|mingw-w64-x86_64-curl|mingw-w64-i686-wintoast|mingw-w64-x86_64-wintoast|bash|heimdal|perl|openssh)
url="$azure_blobs_source_url/$filename"
sf1_url=
sf2_url=
Expand Down
1 change: 1 addition & 0 deletions git-extra/git-sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ sdk () {
mingw-w64-cv2pdb \
mingw-w64-git \
mingw-w64-git-credential-manager \
mingw-w64-git-credential-manager-core \
mingw-w64-git-lfs \
mingw-w64-git-sizer \
mingw-w64-wintoast \
Expand Down
96 changes: 67 additions & 29 deletions installer/install.iss
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,14 @@ const
GP_GitPullRebase = 2;
GP_GitPullFFOnly = 3;

// Git Credential Manager settings.
GCM_None = 1;
GCM_Classic = 2;
GCM_Core = 3;

// Extra options
GP_FSCache = 1;
GP_GCM = 2;
GP_Symlinks = 3;
GP_Symlinks = 2;

#ifdef WITH_EXPERIMENTAL_BUILTIN_DIFFTOOL
#define HAVE_EXPERIMENTAL_OPTIONS 1
Expand Down Expand Up @@ -447,6 +451,10 @@ var
GitPullBehaviorPage:TWizardPage;
RdbGitPullBehavior:array[GP_GitPullMerge..GP_GitPullFFOnly] of TRadioButton;

// Wizard page and variables for the credential manager options.
GitCredentialManagerPage:TWizardPage;
RdbGitCredentialManager:array[GCM_None..GCM_Core] of TRadioButton;

// Wizard page and variables for the extra options.
ExtraOptionsPage:TWizardPage;
RdbExtraOptions:array[GP_FSCache..GP_Symlinks] of TCheckBox;
Expand Down Expand Up @@ -796,6 +804,7 @@ begin
'credential.helper':
case Value of
'manager': RecordInferredDefault('Use Credential Manager','Enabled');
'manager-core': RecordInferredDefault('Use Credential Manager','Core');
else RecordInferredDefault('Use Credential Manager','Disabled');
end;
'core.symlinks':
Expand Down Expand Up @@ -1127,13 +1136,6 @@ begin
ShellExec('','https://stackoverflow.blog/2017/05/23/stack-overflow-helping-one-million-developers-exit-vim/','','',SW_SHOW,ewNoWait,ExitStatus);
end;

procedure OpenGCMHomepage(Sender:TObject);
var
ExitStatus:Integer;
begin
ShellExec('','https://github.com/Microsoft/Git-Credential-Manager-for-Windows','','',SW_SHOW,ewNoWait,ExitStatus);
end;

procedure OpenSymlinksWikiPage(Sender:TObject);
var
ExitStatus:Integer;
Expand Down Expand Up @@ -2060,30 +2062,50 @@ begin
end;

(*
* Create a custom page for extra options.
* Create a custom page for the choice of Git Credential Manager.
*)

ExtraOptionsPage:=CreatePage(PrevPageID,'Configuring extra options','Which features would you like to enable?',TabOrder,Top,Left);
GitCredentialManagerPage:=CreatePage(PrevPageID,'Choose a credential helper','Which credential helper should be configured?',TabOrder,Top,Left);

// 1st option
RdbExtraOptions[GP_FSCache]:=CreateCheckBox(ExtraOptionsPage,'Enable file system caching','File system data will be read in bulk and cached in memory for certain'+#13+'operations ("core.fscache" is set to "true"). This provides a significant'+#13+'performance boost.',TabOrder,Top,Left);
// 1st choice
RdbGitCredentialManager[GCM_None]:=CreateRadioButton(GitCredentialManagerPage,'None','Do not use a credential helper.',TabOrder,Top,Left);

// Restore the settings chosen during a previous install.
RdbExtraOptions[GP_FSCache].Checked:=ReplayChoice('Performance Tweaks FSCache','Enabled')<>'Disabled';
// 2nd choice
RdbGitCredentialManager[GCM_Classic]:=CreateRadioButton(GitCredentialManagerPage,'Git Credential Manager','The <A HREF=https://github.com/Microsoft/Git-Credential-Manager-for-Windows>Git Credential Manager for Windows</A> handles credentials e.g. for Azure'+#13+'DevOps and GitHub (requires .NET framework v4.5.1 or later).',TabOrder,Top,Left);

// 2nd option
RdbExtraOptions[GP_GCM]:=CreateCheckBox(ExtraOptionsPage,'Enable Git Credential Manager','The <A HREF=https://github.com/Microsoft/Git-Credential-Manager-for-Windows>Git Credential Manager for Windows</A> provides secure Git credential storage'+#13+'for Windows, most notably multi-factor authentication support for Visual Studio'+#13+'Team Services and GitHub. (requires .NET framework v4.5.1 or later).',TabOrder,Top,Left);
// 3rd choice
RdbGitCredentialManager[GCM_Core]:=CreateRadioButton(GitCredentialManagerPage,'Git Credential Manager Core','<RED>(NEW!)</RED> Use the new, <A HREF=https://github.com/microsoft/Git-Credential-Manager-Core>cross-platform version of the Git Credential Manager</A>.'+#13+'See more information about the future of Git Credential Manager <A HREF=https://github.com/microsoft/Git-Credential-Manager-Core/blob/master/docs/faq.md#about-the-project>here</A>.',TabOrder,Top,Left);

// Restore the settings chosen during a previous install, if .NET 4.5.1
// or later is available.
if DetectNetFxVersion()<378675 then begin
RdbExtraOptions[GP_GCM].Checked:=False;
RdbExtraOptions[GP_GCM].Enabled:=False;
RdbGitCredentialManager[GCM_Classic].Checked:=False;
RdbGitCredentialManager[GCM_Classic].Enabled:=False;
RdbGitCredentialManager[GCM_Core].Checked:=False;
RdbGitCredentialManager[GCM_Core].Enabled:=False;
end else begin
RdbExtraOptions[GP_GCM].Checked:=ReplayChoice('Use Credential Manager','Enabled')<>'Disabled';
case ReplayChoice('Use Credential Manager','Enabled') of
'Disabled': RdbGitCredentialManager[GCM_None].Checked:=True;
'Enabled': RdbGitCredentialManager[GCM_Classic].Checked:=True;
'Core': RdbGitCredentialManager[GCM_Core].Checked:=True;
else
RdbGitCredentialManager[GCM_Classic].Checked:=True;
end;
end;

// 3rd option
(*
* Create a custom page for extra options.
*)

ExtraOptionsPage:=CreatePage(PrevPageID,'Configuring extra options','Which features would you like to enable?',TabOrder,Top,Left);

// 1st option
RdbExtraOptions[GP_FSCache]:=CreateCheckBox(ExtraOptionsPage,'Enable file system caching','File system data will be read in bulk and cached in memory for certain'+#13+'operations ("core.fscache" is set to "true"). This provides a significant'+#13+'performance boost.',TabOrder,Top,Left);

// Restore the settings chosen during a previous install.
RdbExtraOptions[GP_FSCache].Checked:=ReplayChoice('Performance Tweaks FSCache','Enabled')<>'Disabled';

// 2nd option
RdbExtraOptions[GP_Symlinks]:=CreateCheckBox(ExtraOptionsPage,'Enable symbolic links','Enable <A HREF=https://github.com/git-for-windows/git/wiki/Symbolic-Links>symbolic links</A> (requires the SeCreateSymbolicLink permission).'+#13+'Please note that existing repositories are unaffected by this setting.',TabOrder,Top,Left);

// Restore the settings chosen during a previous install, or auto-detect
Expand Down Expand Up @@ -2788,16 +2810,28 @@ begin
GitSystemConfigSet('pull.ff','only')
end;

{
Configure credential helper
}

if RdbGitCredentialManager[GCM_None].checked then begin
GitSystemConfigSet('credential.helper',#0);
dscho marked this conversation as resolved.
Show resolved Hide resolved
GitSystemConfigSet('credential.https://dev.azure.com.useHttpPath',#0);
end else if RdbGitCredentialManager[GCM_Classic].checked then begin
GitSystemConfigSet('credential.helper','manager');
GitSystemConfigSet('credential.https://dev.azure.com.useHttpPath',#0);
dscho marked this conversation as resolved.
Show resolved Hide resolved
end else if RdbGitCredentialManager[GCM_Core].checked then begin
GitSystemConfigSet('credential.helper','manager-core');
GitSystemConfigSet('credential.https://dev.azure.com.useHttpPath','true');
end;

{
Configure extra options
}

if RdbExtraOptions[GP_FSCache].checked then
GitSystemConfigSet('core.fscache','true');

if RdbExtraOptions[GP_GCM].checked then
GitSystemConfigSet('credential.helper','manager');

if RdbExtraOptions[GP_Symlinks].checked then
Cmd:='true'
else
Expand Down Expand Up @@ -3144,17 +3178,21 @@ begin
end;
RecordChoice(PreviousDataKey,'Git Pull Behavior Option',Data);

// Extra options.
// Credential helper.
Data:='Disabled';
if RdbExtraOptions[GP_FSCache].Checked then begin
if RdbGitCredentialManager[GCM_Classic].Checked then begin
Data:='Enabled';
end else if RdbGitCredentialManager[GCM_Core].Checked then begin;
Data:='Core';
end;
RecordChoice(PreviousDataKey,'Performance Tweaks FSCache',Data);
RecordChoice(PreviousDataKey,'Use Credential Manager',Data);

// Extra options.
Data:='Disabled';
if RdbExtraOptions[GP_GCM].Checked then begin
if RdbExtraOptions[GP_FSCache].Checked then begin
Data:='Enabled';
end;
RecordChoice(PreviousDataKey,'Use Credential Manager',Data);
RecordChoice(PreviousDataKey,'Performance Tweaks FSCache',Data);
Data:='Disabled';
if RdbExtraOptions[GP_Symlinks].Checked then begin
Data:='Enabled';
Expand Down
4 changes: 2 additions & 2 deletions make-file-list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pacman_list () {

# Packages that have been added after Git SDK 1.0.0 was released...
required=
for req in mingw-w64-$ARCH-git-credential-manager $SH_FOR_REBASE \
for req in mingw-w64-$ARCH-git-credential-manager mingw-w64-$ARCH-git-credential-manager-core $SH_FOR_REBASE \
$(test -n "$MINIMAL_GIT" || echo \
mingw-w64-$ARCH-connect git-flow unzip docx2txt \
mingw-w64-$ARCH-antiword mingw-w64-$ARCH-odt2txt \
Expand All @@ -97,7 +97,7 @@ test -z "$required" ||
pacman -Sy --noconfirm $required >&2 ||
die "Could not install required packages: $required"

packages="mingw-w64-$ARCH-git mingw-w64-$ARCH-git-credential-manager
packages="mingw-w64-$ARCH-git mingw-w64-$ARCH-git-credential-manager mingw-w64-$ARCH-git-credential-manager-core
git-extra openssh $UTIL_PACKAGES"
if test -z "$MINIMAL_GIT"
then
Expand Down
29 changes: 29 additions & 0 deletions mingw-w64-git-credential-manager-core/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Maintainer: Johannes Schindelin/Matthew J Cheetham

_realname="git-credential-manager-core"
pkgbase="mingw-w64-${_realname}"
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=2.0.164.25618
pkgrel=0
_realver=$pkgver
_realtag=v${pkgver%.*}-beta
pkgdesc="Credential Manager for Git"
arch=('any')
project_url="https://github.com/microsoft/Git-Credential-Manager-Core"
zip_url="${project_url}/releases/download/${_realtag}/gcmcore-win-x86-${_realver}.zip"
src_zip_url="${project_url}/archive/${_realtag}.zip"
license=('MIT')
groups=('VCS')

source=("${zip_url}" "$src_zip_url")

sha256sums=('a9d424bb56e5571a9a80e195376aa7c7fcf5f890fe1029f45eb81be04eb9d264'
'7b07bf3317ae4e47446a93febe2b6fcde6f409bd3ab3b78358b6dfcc13ab5592')

package() {
prefix="$pkgdir/${MINGW_PREFIX}"
srcdir2="${srcdir}/"
install -d -m755 "${prefix}"/libexec/git-core
install -m755 "$srcdir2"/*.{dll,exe} "${prefix}"/libexec/git-core
install -d -m755 "${prefix}"/doc/git-credential-manager-core
}
44 changes: 44 additions & 0 deletions please.sh
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,15 @@ set_package () {
type=MINGW
pkgpath=/usr/src/build-extra/mingw-w64-git-credential-manager
;;
mingw-w64-git-credential-manager-core)
type=MINGW
pkgpath=/usr/src/build-extra/mingw-w64-git-credential-manager-core
;;
gcm|credential-manager-core|git-credential-manager-core)
package=mingw-w64-git-credential-manager-core
type=MINGW
pkgpath=/usr/src/build-extra/mingw-w64-git-credential-manager-core
;;
lfs|git-lfs|mingw-w64-git-lfs)
package=mingw-w64-git-lfs
type=MINGW
Expand Down Expand Up @@ -2927,6 +2936,41 @@ upgrade () { # [--directory=<artifacts-directory>] [--only-mingw] [--no-build] [
url=https://github.com/$repo/releases/tag/$tag_name &&
release_notes_feature='Comes with [Git Credential Manager v'$version']('"$url"').'
;;
mingw-w64-git-credential-manager-core)
repo=microsoft/Git-Credential-Manager-Core
url=https://api.github.com/repos/$repo/releases/latest
release="$(curl --netrc -s $url)"
test -n "$release" ||
die "Could not determine the latest version of %s\n" "$package"
tag_name="$(echo "$release" |
sed -n 's/^ "tag_name": "\(.*\)",\?$/\1/p')"
zip_name="$(echo "$release" | sed -n \
's/.*"browser_download_url":.*\/\(gcm.*\.zip\).*/\1/p')"
version=${tag_name#v}
zip_prefix=${zip_name%$version.zip}
if test "$zip_prefix" = "$zip_name"
then
# The version in the tag and the zip file name differ
zip_replace='s/^\(zip_url=.*\/\)gcm[^"]*/\1'$zip_name/
else
zip_replace='s/^\(zip_url=.*\/\)gcm[^"]*/\1'$zip_prefix'${_realver}.zip/'
fi
src_zip_prefix=${tag_name%$version}
(cd "$sdk64$pkgpath" &&
sed -i -e "s/^\\(pkgver=\\).*/\1$version/" -e "$zip_replace" \
-e 's/^\(src_zip_url=.*\/\).*\(\$.*\)/\1'$src_zip_prefix'\2/' \
-e 's/^pkgrel=.*/pkgrel=1/' PKGBUILD &&
updpkgsums &&
srcdir2="$(unzip -l $zip_prefix$version.zip | sed -n \
's/^.\{28\} *\(.*\/\)\?git-credential-manager-core.exe/\1/p')" &&
sed -i -e 's/^\( srcdir2=\).*/\1"${srcdir}\/'$srcdir2'"/' \
PKGBUILD &&
maybe_force_pkgrel "$force_pkgrel" &&
git commit -s -m "Upgrade $package to $version${force_pkgrel:+-$force_pkgrel}" PKGBUILD &&
create_bundle_artifact) &&
url=https://github.com/$repo/releases/tag/$tag_name &&
release_notes_feature='Comes with [Git Credential Manager Core v'$version']('"$url"').'
;;
mjcheetham marked this conversation as resolved.
Show resolved Hide resolved
git-extra)
(cd "$sdk64$pkgpath" &&
updpkgsums &&
Expand Down