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

[test optimization] Configuration parameter to disable git unshallow #5291

Merged
merged 7 commits into from
Feb 20, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const FormData = require('../../../exporters/common/form-data')
const request = require('../../../exporters/common/request')

const log = require('../../../log')
const { isFalse } = require('../../../util')
const {
getLatestCommits,
getRepositoryUrl,
Expand Down Expand Up @@ -284,7 +285,9 @@ function sendGitMetadata (url, { isEvpProxy, evpProxyPrefix }, configRepositoryU
}
// Otherwise we unshallow and get commits to upload again
log.debug('It is shallow clone, unshallowing...')
unshallowRepository()
if (!isFalse(process.env.DD_CIVISIBILITY_GIT_UNSHALLOW_ENABLED)) {
unshallowRepository()
}

// The latest commits change after unshallowing
latestCommits = getLatestCommits()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ describe('git_metadata', () => {

after(() => {
delete process.env.DD_API_KEY
delete process.env.DD_CIVISIBILITY_GIT_UNSHALLOW_ENABLED
fs.unlinkSync(temporaryPackFile)
fs.unlinkSync(secondTemporaryPackFile)
})
Expand Down Expand Up @@ -97,6 +98,25 @@ describe('git_metadata', () => {
})
})

it('should not unshallow if the parameter to enable unshallow is false', (done) => {
process.env.DD_CIVISIBILITY_GIT_UNSHALLOW_ENABLED = false
const scope = nock('https://api.test.com')
.post('/api/v2/git/repository/search_commits')
.reply(200, JSON.stringify({ data: [] }))
.post('/api/v2/git/repository/search_commits') // calls a second time after unshallowing
.reply(200, JSON.stringify({ data: [] }))
.post('/api/v2/git/repository/packfile')
.reply(204)

isShallowRepositoryStub.returns(true)
gitMetadata.sendGitMetadata(new URL('https://api.test.com'), { isEvpProxy: false }, '', (err) => {
expect(unshallowRepositoryStub).not.to.have.been.called
expect(err).to.be.null
expect(scope.isDone()).to.be.true
done()
})
})

it('should request to /api/v2/git/repository/search_commits and /api/v2/git/repository/packfile', (done) => {
const scope = nock('https://api.test.com')
.post('/api/v2/git/repository/search_commits')
Expand Down
Loading