-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from s0/folder-spaces
Handle folders with spaces
- Loading branch information
Showing
4 changed files
with
78 additions
and
2 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
10 changes: 10 additions & 0 deletions
10
action/test/specs/__snapshots__/ssh-existing-branch-folder-space.spec.ts.snap
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,10 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Spaces in folder names are correctly handled 1`] = ` | ||
"msg:Update master to output generated at <sha> | ||
tree:3f97adec519b4ce0c5950da8eb91bd2939d20689 | ||
author:s0 <[email protected]> | ||
msg:initial | ||
tree:c1cde76c408d7c8cb6956f35f1e4853366340aec | ||
author:Test User <[email protected]>" | ||
`; |
66 changes: 66 additions & 0 deletions
66
action/test/specs/ssh-existing-branch-folder-space.spec.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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import * as path from 'path'; | ||
|
||
import * as util from '../util'; | ||
|
||
const REPO_DIR = path.join( | ||
util.REPOS_DIR, | ||
'ssh-existing-branch-folder-space.git' | ||
); | ||
const WORK_DIR = path.join(util.DATA_DIR, 'ssh-existing-branch-folder-space'); | ||
const REPO_CLONE_DIR = path.join(WORK_DIR, 'clone'); | ||
const DATA_DIR = path.join(WORK_DIR, 'data with space'); | ||
|
||
it('Spaces in folder names are correctly handled', async () => { | ||
// Create empty repo | ||
await util.mkdir(REPO_DIR); | ||
await util.wrappedExec('git init --bare', { cwd: REPO_DIR }); | ||
|
||
// Clone repo, and create an initial commit | ||
await util.mkdir(WORK_DIR); | ||
await util.wrappedExec(`git clone "${REPO_DIR}" clone`, { cwd: WORK_DIR }); | ||
await util.writeFile(path.join(REPO_CLONE_DIR, 'initial'), 'foobar'); | ||
await util.wrappedExec(`git add -A .`, { cwd: REPO_CLONE_DIR }); | ||
await util.wrappedExec(`git config user.name "Test User"`, { | ||
cwd: REPO_CLONE_DIR, | ||
}); | ||
await util.wrappedExec(`git config user.email "[email protected]"`, { | ||
cwd: REPO_CLONE_DIR, | ||
}); | ||
await util.wrappedExec(`git commit -m initial`, { cwd: REPO_CLONE_DIR }); | ||
await util.wrappedExec(`git push origin master`, { cwd: REPO_CLONE_DIR }); | ||
|
||
// Create dummy data | ||
await util.mkdir(DATA_DIR); | ||
await util.mkdir(path.join(DATA_DIR, 'dummy foo')); | ||
await util.writeFile(path.join(DATA_DIR, 'dummy foo', 'baz'), 'foobar'); | ||
await util.writeFile(path.join(DATA_DIR, 'dummy foo', '.bat'), 'foobar'); | ||
|
||
// Run Action | ||
await util.runWithGithubEnv( | ||
path.basename(__filename), | ||
{ | ||
REPO: 'ssh://git@git-ssh/git-server/repos/ssh-existing-branch-folder-space.git', | ||
BRANCH: 'master', | ||
FOLDER: DATA_DIR, | ||
SSH_PRIVATE_KEY: (await util.readFile(util.SSH_PRIVATE_KEY)).toString(), | ||
KNOWN_HOSTS_FILE: util.KNOWN_HOSTS, | ||
}, | ||
's0/test', | ||
{}, | ||
's0' | ||
); | ||
|
||
// Check that the log of the repo is as expected | ||
// (check tree-hash, commit message, and author) | ||
const log = ( | ||
await util.exec( | ||
'git log --pretty="format:msg:%s%ntree:%T%nauthor:%an <%ae>" master', | ||
{ | ||
cwd: REPO_DIR, | ||
} | ||
) | ||
).stdout; | ||
const sha = await util.getRepoSha(); | ||
const cleanedLog = log.replace(sha, '<sha>'); | ||
expect(cleanedLog).toMatchSnapshot(); | ||
}); |