-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a117dcf
commit 63b75f0
Showing
4 changed files
with
62 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -484,6 +484,10 @@ gitWithCreds 'https://your.repo' // Implicitly passed credentials | |
* `git.setTag('tag', 'message', 'Author', '[email protected])` | ||
* `git.setTag('tag', 'message')` - uses the name and email of the last committer as author and committer. | ||
* `git.fetch()` | ||
* `git.pull()` - pulls, and in case of merge, uses the name and email of the last committer as author and committer. | ||
* `git.pull('refspec')` - pulls specific refspec (e.g. `origin master`), and in case of merge, uses the name and email | ||
of the last committer as author and committer. | ||
* `git.pull('refspec', 'Author', '[email protected])` | ||
* `git.merge('develop', 'Author', '[email protected])` | ||
* `git.merge('develop')` - uses the name and email of the last committer as author and committer. | ||
* `git.mergeFastForwardOnly('master')` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,9 +190,7 @@ class GitTest { | |
|
||
@Test | ||
void commit() { | ||
ScriptMock scriptMock = new ScriptMock() | ||
scriptMock.expectedDefaultShRetValue = "User Name <[email protected]>" | ||
Git git = new Git(scriptMock) | ||
git.commit 'msg' | ||
def actualWithEnv = scriptMock.actualWithEnvAsMap() | ||
assert actualWithEnv['GIT_AUTHOR_NAME'] == 'User Name' | ||
|
@@ -203,9 +201,7 @@ class GitTest { | |
|
||
@Test | ||
void setTag() { | ||
ScriptMock scriptMock = new ScriptMock() | ||
scriptMock.expectedDefaultShRetValue = "User Name <[email protected]>" | ||
Git git = new Git(scriptMock) | ||
git.setTag("someTag", "someMessage") | ||
def actualWithEnv = scriptMock.actualWithEnvAsMap() | ||
|
||
|
@@ -224,6 +220,44 @@ class GitTest { | |
assert scriptMock.actualShStringArgs[1] == "git fetch --all" | ||
} | ||
|
||
@Test | ||
void pull() { | ||
def expectedGitCommandWithCredentials = 'git -c credential.helper="!f() { echo username=\'$GIT_AUTH_USR\'; echo password=\'$GIT_AUTH_PSW\'; }; f" pull' | ||
scriptMock.expectedShRetValueForScript.put(expectedGitCommandWithCredentials, 0) | ||
scriptMock.expectedShRetValueForScript.put('git --no-pager show -s --format=\'%an <%ae>\' HEAD', 'User Name <[email protected]>') | ||
git = new Git(scriptMock, 'creds') | ||
|
||
git.pull() | ||
|
||
def actualWithEnv = scriptMock.actualWithEnvAsMap() | ||
assert actualWithEnv['GIT_AUTHOR_NAME'] == 'User Name' | ||
assert actualWithEnv['GIT_COMMITTER_NAME'] == 'User Name' | ||
assert actualWithEnv['GIT_AUTHOR_EMAIL'] == '[email protected]' | ||
assert actualWithEnv['GIT_COMMITTER_EMAIL'] == '[email protected]' | ||
|
||
assert scriptMock.actualShMapArgs.size() == 3 | ||
assert scriptMock.actualShMapArgs.get(2).trim() == expectedGitCommandWithCredentials | ||
} | ||
|
||
@Test | ||
void 'pull with refspec'() { | ||
def expectedGitCommandWithCredentials = 'git -c credential.helper="!f() { echo username=\'$GIT_AUTH_USR\'; echo password=\'$GIT_AUTH_PSW\'; }; f" pull origin master' | ||
scriptMock.expectedShRetValueForScript.put(expectedGitCommandWithCredentials, 0) | ||
scriptMock.expectedShRetValueForScript.put('git --no-pager show -s --format=\'%an <%ae>\' HEAD', 'User Name <[email protected]>') | ||
git = new Git(scriptMock, 'creds') | ||
|
||
git.pull 'origin master' | ||
|
||
def actualWithEnv = scriptMock.actualWithEnvAsMap() | ||
assert actualWithEnv['GIT_AUTHOR_NAME'] == 'User Name' | ||
assert actualWithEnv['GIT_COMMITTER_NAME'] == 'User Name' | ||
assert actualWithEnv['GIT_AUTHOR_EMAIL'] == '[email protected]' | ||
assert actualWithEnv['GIT_COMMITTER_EMAIL'] == '[email protected]' | ||
|
||
assert scriptMock.actualShMapArgs.size() == 3 | ||
assert scriptMock.actualShMapArgs.get(2).trim() == expectedGitCommandWithCredentials | ||
} | ||
|
||
@Test | ||
void checkout() { | ||
git.checkout("master") | ||
|
@@ -264,24 +298,20 @@ class GitTest { | |
|
||
@Test | ||
void mergeFastForwardOnly() { | ||
ScriptMock scriptMock = new ScriptMock() | ||
Git git = new Git(scriptMock) | ||
git.mergeFastForwardOnly("master") | ||
|
||
assert scriptMock.actualShStringArgs[0] == "git merge --ff-only master" | ||
} | ||
|
||
@Test | ||
void push() { | ||
ScriptMock scriptMock = new ScriptMock() | ||
scriptMock.expectedShRetValueForScript.put('git -c credential.helper="!f() { echo username=\'$GIT_AUTH_USR\'; echo password=\'$GIT_AUTH_PSW\'; }; f" push origin master', 0) | ||
git = new Git(scriptMock, 'creds') | ||
git.push('master') | ||
} | ||
|
||
@Test | ||
void pushNonHttps() { | ||
ScriptMock scriptMock = new ScriptMock() | ||
scriptMock.expectedShRetValueForScript.put('git -c credential.helper="!f() { echo username=\'$GIT_AUTH_USR\'; echo password=\'$GIT_AUTH_PSW\'; }; f" push origin master', 0) | ||
git = new Git(scriptMock, 'creds') | ||
git.push('master') | ||
|
@@ -292,7 +322,6 @@ class GitTest { | |
|
||
@Test | ||
void pushWithRetry() { | ||
ScriptMock scriptMock = new ScriptMock() | ||
scriptMock.expectedShRetValueForScript.put('git -c credential.helper="!f() { echo username=\'$GIT_AUTH_USR\'; echo password=\'$GIT_AUTH_PSW\'; }; f" push origin master', [128, 128, 0]) | ||
git = new Git(scriptMock, 'creds') | ||
git.retryTimeout = 1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters