Merged in fix/ensure-fetch-head-exists-in-branch-sync (pull request #2770)
fix: Always run git fetch in netlify-branch-sync * Always run git fetch If we don't run git fetch `FETCH_HEAD` will not be set, since git clone does not set it. Approved-by: Joakim Jäderberg
This commit is contained in:
@@ -98,19 +98,7 @@ export const onPreBuild = async function ({ utils }) {
|
||||
}
|
||||
}
|
||||
|
||||
if (existsSync(CLONE_DIR)) {
|
||||
// Fetch if already cloned.
|
||||
logger.debug(`Fetching from origin`)
|
||||
|
||||
await run("git", [
|
||||
"-C",
|
||||
CLONE_DIR,
|
||||
"fetch",
|
||||
"--no-tags",
|
||||
"origin",
|
||||
SYNC_SOURCE,
|
||||
])
|
||||
} else {
|
||||
if (!existsSync(CLONE_DIR)) {
|
||||
// Clone if there is no clone.
|
||||
const token = process.env.BITBUCKET_ACCESS_TOKEN ?? ""
|
||||
const cloneURL = `https://x-token-auth:${token}@bitbucket.org/scandic-swap/web.git`
|
||||
@@ -118,16 +106,14 @@ export const onPreBuild = async function ({ utils }) {
|
||||
logger.debug(`Cloning from ${cloneURL.replace(token, "****")}`)
|
||||
logger.debug(`Cloning to ${CLONE_DIR}`)
|
||||
|
||||
await run("git", [
|
||||
"clone",
|
||||
"--bare",
|
||||
"--branch",
|
||||
SYNC_SOURCE,
|
||||
cloneURL,
|
||||
CLONE_DIR,
|
||||
])
|
||||
await run("git", ["clone", "--bare", "--branch", SYNC_SOURCE, cloneURL, CLONE_DIR])
|
||||
}
|
||||
|
||||
// Always fetch to ensure FETCH_HEAD is available
|
||||
logger.debug(`Fetching from origin`)
|
||||
|
||||
await run("git", ["-C", CLONE_DIR, "fetch", "--no-tags", "origin", SYNC_SOURCE])
|
||||
|
||||
logger.debug(`Attempting to sync: ${SYNC_DEST.join(", ")}`)
|
||||
|
||||
for (let i = 0; i < SYNC_DEST.length; ++i) {
|
||||
|
||||
Reference in New Issue
Block a user