Skip to content

Commit

Permalink
fix: finally write default values
Browse files Browse the repository at this point in the history
  • Loading branch information
CasLubbers committed Jul 26, 2024
1 parent 28fe5f3 commit 0e30eab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Empty file removed src/common/bootstrap.test.ts
Empty file.
22 changes: 15 additions & 7 deletions src/common/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ export const bootstrapGit = async (inValues?: Record<string, any>): Promise<void
}
// we know we have commits, so we replace ENV_DIR with the clone files and overwrite with new values
// so first get the new values without secrets (as those exist already)
// const newValues = (await hfValues({ filesOnly: true })) as Record<string, any>
cd(env.ENV_DIR)
// then sync the clone back to ENV_DIR
const flags = '-rl' // recursive, preserve symlinks and groups (all we can do without superuser privs)
Expand All @@ -87,22 +86,31 @@ export const bootstrapGit = async (inValues?: Record<string, any>): Promise<void
} catch (e) {
d.debug(e)
d.info('Remote does not exist yet. Expecting first commit to come later.')
} finally {
// finally write back the new values without overwriting existing values
d.info('Write default values to env repo')
await writeValues(values)
}
// finally write back the new values without overwriting existing values
d.info('Write default values to env repo')
await writeValues(values)

if (!(await pathExists(`${env.ENV_DIR}/.git`))) {
d.info('Initializing values git repo.')
await $`git init .`
}
if (isCli) await copyFile(`${rootDir}/bin/hooks/pre-commit`, `${env.ENV_DIR}/.git/hooks/pre-commit`)
else await nothrow($`git config --global --add safe.directory ${env.ENV_DIR}`)

if (isCli) {
await copyFile(`${rootDir}/bin/hooks/pre-commit`, `${env.ENV_DIR}/.git/hooks/pre-commit`)
} else {
await nothrow($`git config --global --add safe.directory ${env.ENV_DIR}`)
}

await setIdentity(username, password, email)

if (!hasCommits) {
await nothrow($`git checkout -b ${branch}`)
await nothrow($`git remote add origin ${remote}`)
}
if (await pathExists(`${env.ENV_DIR}/.sops.yaml`))
if (await pathExists(`${env.ENV_DIR}/.sops.yaml`)) {
await nothrow($`git config --local diff.sopsdiffer.textconv "sops -d"`)
}
d.log(`Done bootstrapping git`)
}

0 comments on commit 0e30eab

Please sign in to comment.