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 new flag GIT_HTTP_MOCK_SERVER_PERSIST_CHANGES #15

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ Same thing for SSH:
- `GIT_SSH_MOCK_SERVER_ROOT` default is `process.cwd()`
- `GIT_SSH_MOCK_SERVER_PASSWORD` activate Password Authentication and use this password (leave blank to allow anonymous SSH access.)
- `GIT_SSH_MOCK_SERVER_PUBKEY` activate PubKey Authentication using the self-generated keypair (leave blank to allow anonymous SSH access.)
- `GIT_HTTP_MOCK_SERVER_PERSIST_CHANGES` set to 'yes' to disable copy-on-write and write changes to the filesystem

### .htpasswd support (http-only)

Expand Down
3 changes: 2 additions & 1 deletion http-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ var cors = require('./cors')
var config = {
root: path.resolve(process.cwd(), process.env.GIT_HTTP_MOCK_SERVER_ROOT || '.'),
glob: '*',
route: process.env.GIT_HTTP_MOCK_SERVER_ROUTE || '/'
route: process.env.GIT_HTTP_MOCK_SERVER_ROUTE || '/',
persistChanges: process.env.GIT_HTTP_MOCK_SERVER_PERSIST_CHANGES === 'yes' || false,
}

var server = http.createServer(cors(factory(config)))
Expand Down
2 changes: 1 addition & 1 deletion middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function factory (config) {
if (service === 'git-receive-pack') {
let gitdir = u.pathname.replace(config.route, '').replace(/\/git-receive-pack$/, '').replace(/^\//, '')
let fixtureName = path.posix.basename(gitdir)
return f.copy(fixtureName)
return config.persistChanges ? f.find(fixtureName) :f.copy(fixtureName)
}
}
return null
Expand Down