-
-
Notifications
You must be signed in to change notification settings - Fork 436
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: update author and committer input defaults * Update github-actions[bot] * Update author to new email format * feat: optional input for git ops token * feat: allow push-to-fork to push to sibling repos (#2414) Fixes #2412. * build: update dist * feat: update action runtime to node 20 (#2340) * feat: add truncate warning to pull request body * perf: unshallow only when necessary * fix: remove the remote for the fork on completion * feat: infer github server and api urls * test: integration test fixes * build: bump major version * docs: update to v6 --------- Co-authored-by: Teko <112829523+Teko012@users.noreply.github.com> Co-authored-by: Benjamin Gilbert <bgilbert@backtick.net>
- Loading branch information
1 parent
bb80902
commit b1ddad2
Showing
24 changed files
with
619 additions
and
490 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
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 |
---|---|---|
|
@@ -11,8 +11,8 @@ on: | |
type: choice | ||
description: The major version tag to update | ||
options: | ||
- v4 | ||
- v5 | ||
- v6 | ||
|
||
jobs: | ||
tag: | ||
|
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
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
58 changes: 37 additions & 21 deletions
58
__test__/git-auth-helper.int.test.ts → __test__/git-config-helper.int.test.ts
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 |
---|---|---|
@@ -1,70 +1,86 @@ | ||
import {GitCommandManager} from '../lib/git-command-manager' | ||
import {GitAuthHelper} from '../lib/git-auth-helper' | ||
import {GitConfigHelper} from '../lib/git-config-helper' | ||
|
||
const REPO_PATH = '/git/local/test-base' | ||
const REPO_PATH = '/git/local/repos/test-base' | ||
|
||
const extraheaderConfigKey = 'http.https://github.com/.extraheader' | ||
const extraheaderConfigKey = 'http.https://127.0.0.1/.extraheader' | ||
|
||
describe('git-auth-helper tests', () => { | ||
describe('git-config-helper integration tests', () => { | ||
let git: GitCommandManager | ||
let gitAuthHelper: GitAuthHelper | ||
let gitConfigHelper: GitConfigHelper | ||
|
||
beforeAll(async () => { | ||
git = await GitCommandManager.create(REPO_PATH) | ||
gitAuthHelper = new GitAuthHelper(git) | ||
}) | ||
|
||
it('tests save and restore with no persisted auth', async () => { | ||
await gitAuthHelper.savePersistedAuth() | ||
await gitAuthHelper.restorePersistedAuth() | ||
const gitConfigHelper = await GitConfigHelper.create(git) | ||
await gitConfigHelper.close() | ||
}) | ||
|
||
it('tests configure and removal of auth', async () => { | ||
await gitAuthHelper.configureToken('github-token') | ||
const gitConfigHelper = await GitConfigHelper.create(git) | ||
await gitConfigHelper.configureToken('github-token') | ||
expect(await git.configExists(extraheaderConfigKey)).toBeTruthy() | ||
expect(await git.getConfigValue(extraheaderConfigKey)).toEqual( | ||
'AUTHORIZATION: basic eC1hY2Nlc3MtdG9rZW46Z2l0aHViLXRva2Vu' | ||
) | ||
|
||
await gitAuthHelper.removeAuth() | ||
await gitConfigHelper.close() | ||
expect(await git.configExists(extraheaderConfigKey)).toBeFalsy() | ||
}) | ||
|
||
it('tests save and restore of persisted auth', async () => { | ||
const extraheaderConfigValue = 'AUTHORIZATION: basic ***persisted-auth***' | ||
await git.config(extraheaderConfigKey, extraheaderConfigValue) | ||
|
||
await gitAuthHelper.savePersistedAuth() | ||
const gitConfigHelper = await GitConfigHelper.create(git) | ||
|
||
const exists = await git.configExists(extraheaderConfigKey) | ||
expect(exists).toBeFalsy() | ||
|
||
await gitAuthHelper.restorePersistedAuth() | ||
await gitConfigHelper.close() | ||
|
||
const configValue = await git.getConfigValue(extraheaderConfigKey) | ||
expect(configValue).toEqual(extraheaderConfigValue) | ||
|
||
await gitAuthHelper.removeAuth() | ||
const unset = await git.tryConfigUnset( | ||
extraheaderConfigKey, | ||
'^AUTHORIZATION:' | ||
) | ||
expect(unset).toBeTruthy() | ||
}) | ||
|
||
it('tests adding and removing the safe.directory config', async () => { | ||
it('tests not adding/removing the safe.directory config when it already exists', async () => { | ||
await git.config('safe.directory', '/another-value', true, true) | ||
|
||
await gitAuthHelper.removeSafeDirectory() | ||
await gitAuthHelper.addSafeDirectory() | ||
const gitConfigHelper = await GitConfigHelper.create(git) | ||
|
||
expect( | ||
await git.configExists('safe.directory', '/another-value', true) | ||
).toBeTruthy() | ||
|
||
await gitConfigHelper.close() | ||
|
||
const unset = await git.tryConfigUnset( | ||
'safe.directory', | ||
'/another-value', | ||
true | ||
) | ||
expect(unset).toBeTruthy() | ||
}) | ||
|
||
it('tests adding and removing the safe.directory config', async () => { | ||
const gitConfigHelper = await GitConfigHelper.create(git) | ||
|
||
expect( | ||
await git.configExists('safe.directory', REPO_PATH, true) | ||
).toBeTruthy() | ||
|
||
await gitAuthHelper.addSafeDirectory() | ||
await gitAuthHelper.removeSafeDirectory() | ||
await gitConfigHelper.close() | ||
|
||
expect( | ||
await git.configExists('safe.directory', REPO_PATH, true) | ||
).toBeFalsy() | ||
expect( | ||
await git.configExists('safe.directory', '/another-value', true) | ||
).toBeTruthy() | ||
}) | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import {GitConfigHelper} from '../lib/git-config-helper' | ||
|
||
describe('git-config-helper unit tests', () => { | ||
test('parseGitRemote successfully parses HTTPS remote URLs', async () => { | ||
const remote1 = GitConfigHelper.parseGitRemote( | ||
'https://github.com/peter-evans/create-pull-request' | ||
) | ||
expect(remote1.hostname).toEqual('github.com') | ||
expect(remote1.protocol).toEqual('HTTPS') | ||
expect(remote1.repository).toEqual('peter-evans/create-pull-request') | ||
|
||
const remote2 = GitConfigHelper.parseGitRemote( | ||
'https://xxx:x-oauth-basic@github.com/peter-evans/create-pull-request' | ||
) | ||
expect(remote2.hostname).toEqual('github.com') | ||
expect(remote2.protocol).toEqual('HTTPS') | ||
expect(remote2.repository).toEqual('peter-evans/create-pull-request') | ||
|
||
const remote3 = GitConfigHelper.parseGitRemote( | ||
'https://github.com/peter-evans/create-pull-request.git' | ||
) | ||
expect(remote3.hostname).toEqual('github.com') | ||
expect(remote3.protocol).toEqual('HTTPS') | ||
expect(remote3.repository).toEqual('peter-evans/create-pull-request') | ||
|
||
const remote4 = GitConfigHelper.parseGitRemote( | ||
'https://github.com/peter-evans/ungit' | ||
) | ||
expect(remote4.hostname).toEqual('github.com') | ||
expect(remote4.protocol).toEqual('HTTPS') | ||
expect(remote4.repository).toEqual('peter-evans/ungit') | ||
|
||
const remote5 = GitConfigHelper.parseGitRemote( | ||
'https://github.com/peter-evans/ungit.git' | ||
) | ||
expect(remote5.hostname).toEqual('github.com') | ||
expect(remote5.protocol).toEqual('HTTPS') | ||
expect(remote5.repository).toEqual('peter-evans/ungit') | ||
|
||
const remote6 = GitConfigHelper.parseGitRemote( | ||
'https://github.internal.company/peter-evans/create-pull-request' | ||
) | ||
expect(remote6.hostname).toEqual('github.internal.company') | ||
expect(remote6.protocol).toEqual('HTTPS') | ||
expect(remote6.repository).toEqual('peter-evans/create-pull-request') | ||
}) | ||
|
||
test('parseGitRemote successfully parses SSH remote URLs', async () => { | ||
const remote1 = GitConfigHelper.parseGitRemote( | ||
'git@github.com:peter-evans/create-pull-request.git' | ||
) | ||
expect(remote1.hostname).toEqual('github.com') | ||
expect(remote1.protocol).toEqual('SSH') | ||
expect(remote1.repository).toEqual('peter-evans/create-pull-request') | ||
|
||
const remote2 = GitConfigHelper.parseGitRemote( | ||
'git@github.com:peter-evans/ungit.git' | ||
) | ||
expect(remote2.hostname).toEqual('github.com') | ||
expect(remote2.protocol).toEqual('SSH') | ||
expect(remote2.repository).toEqual('peter-evans/ungit') | ||
|
||
const remote3 = GitConfigHelper.parseGitRemote( | ||
'git@github.internal.company:peter-evans/create-pull-request.git' | ||
) | ||
expect(remote3.hostname).toEqual('github.internal.company') | ||
expect(remote3.protocol).toEqual('SSH') | ||
expect(remote3.repository).toEqual('peter-evans/create-pull-request') | ||
}) | ||
|
||
test('parseGitRemote successfully parses GIT remote URLs', async () => { | ||
// Unauthenticated git protocol for integration tests only | ||
const remote1 = GitConfigHelper.parseGitRemote( | ||
'git://127.0.0.1/repos/test-base.git' | ||
) | ||
expect(remote1.hostname).toEqual('127.0.0.1') | ||
expect(remote1.protocol).toEqual('GIT') | ||
expect(remote1.repository).toEqual('repos/test-base') | ||
}) | ||
|
||
test('parseGitRemote fails to parse a remote URL', async () => { | ||
const remoteUrl = 'https://github.com/peter-evans' | ||
try { | ||
GitConfigHelper.parseGitRemote(remoteUrl) | ||
// Fail the test if an error wasn't thrown | ||
expect(true).toEqual(false) | ||
} catch (e: any) { | ||
expect(e.message).toEqual( | ||
`The format of '${remoteUrl}' is not a valid GitHub repository URL` | ||
) | ||
} | ||
}) | ||
}) |
Oops, something went wrong.