@@ -1700,31 +1700,29 @@ mktempdir() do dir
1700
1700
# In order to use the "store" credential helper `git` needs to be installed and
1701
1701
# on the path.
1702
1702
if GIT_INSTALLED
1703
- config_path = joinpath (dir, config_file)
1704
1703
credential_path = joinpath (dir, " .git-credentials" )
1705
-
1706
- isfile (config_path) && rm (config_path)
1707
1704
isfile (credential_path) && rm (credential_path)
1708
1705
1709
- LibGit2 . with (LibGit2 . GitConfig (config_path, LibGit2 . Consts . CONFIG_LEVEL_APP)) do cfg
1710
- @test isempty (LibGit2. get (cfg , " credential.helper " , " " ) )
1706
+ # Requires `git` to be installed and available on the path.
1707
+ helper = parse (LibGit2. GitCredentialHelper , " store " )
1711
1708
1712
- helper = parse (LibGit2. GitCredentialHelper, " store" ) # Requires `git`
1713
- LibGit2. set! (cfg, " credential.helper" , " store --file $credential_path " )
1709
+ # Set HOME to control where the .git-credentials file is written.
1710
+ # Note: In Cygwin environments `git` will use HOME instead of USERPROFILE.
1711
+ # Setting both environment variables ensures home was overridden.
1712
+ withenv (" HOME" => dir, " USERPROFILE" => dir) do
1713
+ query = LibGit2. GitCredential (" https" , " mygithost" )
1714
+ filled = LibGit2. GitCredential (" https" , " mygithost" , nothing , " bob" , " s3cre7" )
1714
1715
1715
- # Set HOME to control where .git-credentials file is written.
1716
- withenv (HOME => dir) do
1717
- query = LibGit2. GitCredential (" https" , " mygithost" )
1718
- filled = LibGit2. GitCredential (" https" , " mygithost" , nothing , " bob" , " s3cre7" )
1716
+ @test ! isfile (credential_path)
1719
1717
1720
- @test LibGit2. fill! (helper, deepcopy (query)) == query
1718
+ @test LibGit2. fill! (helper, deepcopy (query)) == query
1721
1719
1722
- LibGit2. approve (helper, filled)
1723
- @test LibGit2. fill! (helper, deepcopy (query)) == filled
1720
+ LibGit2. approve (helper, filled)
1721
+ @test isfile (credential_path)
1722
+ @test LibGit2. fill! (helper, deepcopy (query)) == filled
1724
1723
1725
- LibGit2. reject (helper, filled)
1726
- @test LibGit2. fill! (helper, deepcopy (query)) == query
1727
- end
1724
+ LibGit2. reject (helper, filled)
1725
+ @test LibGit2. fill! (helper, deepcopy (query)) == query
1728
1726
end
1729
1727
end
1730
1728
end
@@ -1733,53 +1731,50 @@ mktempdir() do dir
1733
1731
# In order to use the "store" credential helper `git` needs to be installed and
1734
1732
# on the path.
1735
1733
if GIT_INSTALLED
1736
- config_path = joinpath (dir, config_file)
1737
1734
credential_path = joinpath (dir, " .git-credentials" )
1738
-
1739
- isfile (config_path) && rm (config_path)
1740
1735
isfile (credential_path) && rm (credential_path)
1741
1736
1742
- LibGit2 . with (LibGit2 . GitConfig (config_path, LibGit2 . Consts . CONFIG_LEVEL_APP)) do cfg
1743
- @test isempty (LibGit2. get (cfg , " credential.helper " , " " ) )
1737
+ # Requires `git` to be installed and available on the path.
1738
+ helper = parse (LibGit2. GitCredentialHelper , " store " )
1744
1739
1745
- helper = parse (LibGit2. GitCredentialHelper, " store" ) # Requires `git`
1746
- LibGit2. set! (cfg, " credential.helper" , " store --file $credential_path " )
1747
- LibGit2. set! (cfg, " credential.useHttpPath" , " true" )
1740
+ # Set HOME to control where the .git-credentials file is written.
1741
+ # Note: In Cygwin environments `git` will use HOME instead of USERPROFILE.
1742
+ # Setting both environment variables ensures home was overridden.
1743
+ withenv (" HOME" => dir, " USERPROFILE" => dir) do
1744
+ query = LibGit2. GitCredential (" https" , " mygithost" )
1745
+ query_a = LibGit2. GitCredential (" https" , " mygithost" , " a" )
1746
+ query_b = LibGit2. GitCredential (" https" , " mygithost" , " b" )
1748
1747
1749
- # Set HOME to control where .git-credentials file is written.
1750
- withenv (HOME => dir) do
1751
- query = LibGit2. GitCredential (" https" , " mygithost" )
1752
- query_a = LibGit2. GitCredential (" https" , " mygithost" , " a" )
1753
- query_b = LibGit2. GitCredential (" https" , " mygithost" , " b" )
1748
+ filled_a = LibGit2. GitCredential (" https" , " mygithost" , " a" , " alice" , " 1234" )
1749
+ filled_b = LibGit2. GitCredential (" https" , " mygithost" , " b" , " bob" , " s3cre7" )
1754
1750
1755
- filled_a = LibGit2. GitCredential (" https" , " mygithost" , " a" , " alice" , " 1234" )
1756
- filled_b = LibGit2. GitCredential (" https" , " mygithost" , " b" , " bob" , " s3cre7" )
1751
+ function without_path (cred)
1752
+ c = deepcopy (cred)
1753
+ c. path = Nullable ()
1754
+ c
1755
+ end
1757
1756
1758
- function without_path (cred)
1759
- c = deepcopy (cred)
1760
- c. path = Nullable ()
1761
- c
1762
- end
1757
+ @test ! isfile (credential_path)
1763
1758
1764
- @test LibGit2. fill! (helper, deepcopy (query)) == query
1765
- @test LibGit2. fill! (helper, deepcopy (query_a)) == query_a
1766
- @test LibGit2. fill! (helper, deepcopy (query_b)) == query_b
1759
+ @test LibGit2. fill! (helper, deepcopy (query)) == query
1760
+ @test LibGit2. fill! (helper, deepcopy (query_a)) == query_a
1761
+ @test LibGit2. fill! (helper, deepcopy (query_b)) == query_b
1767
1762
1768
- LibGit2. approve (helper, filled_a)
1769
- @test LibGit2. fill! (helper, deepcopy (query)) == without_path (filled_a)
1770
- @test LibGit2. fill! (helper, deepcopy (query_a)) == filled_a
1771
- @test LibGit2. fill! (helper, deepcopy (query_b)) == query_b
1763
+ LibGit2. approve (helper, filled_a)
1764
+ @test isfile (credential_path)
1765
+ @test LibGit2. fill! (helper, deepcopy (query)) == without_path (filled_a)
1766
+ @test LibGit2. fill! (helper, deepcopy (query_a)) == filled_a
1767
+ @test LibGit2. fill! (helper, deepcopy (query_b)) == query_b
1772
1768
1773
- LibGit2. approve (helper, filled_b)
1774
- @test LibGit2. fill! (helper, deepcopy (query)) == without_path (filled_b)
1775
- @test LibGit2. fill! (helper, deepcopy (query_a)) == filled_a
1776
- @test LibGit2. fill! (helper, deepcopy (query_b)) == filled_b
1769
+ LibGit2. approve (helper, filled_b)
1770
+ @test LibGit2. fill! (helper, deepcopy (query)) == without_path (filled_b)
1771
+ @test LibGit2. fill! (helper, deepcopy (query_a)) == filled_a
1772
+ @test LibGit2. fill! (helper, deepcopy (query_b)) == filled_b
1777
1773
1778
- LibGit2. reject (helper, filled_b)
1779
- @test LibGit2. fill! (helper, deepcopy (query)) == without_path (filled_a)
1780
- @test LibGit2. fill! (helper, deepcopy (query_a)) == filled_a
1781
- @test LibGit2. fill! (helper, deepcopy (query_b)) == query_b
1782
- end
1774
+ LibGit2. reject (helper, filled_b)
1775
+ @test LibGit2. fill! (helper, deepcopy (query)) == without_path (filled_a)
1776
+ @test LibGit2. fill! (helper, deepcopy (query_a)) == filled_a
1777
+ @test LibGit2. fill! (helper, deepcopy (query_b)) == query_b
1783
1778
end
1784
1779
end
1785
1780
end
0 commit comments