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

ci: safe.directory #1250

Closed
casperdcl opened this issue Nov 4, 2022 · 3 comments
Closed

ci: safe.directory #1250

casperdcl opened this issue Nov 4, 2022 · 3 comments
Assignees
Labels
cml-ci Subcommand enhancement New feature or request

Comments

@casperdcl
Copy link
Contributor

from iterative/stale-model-example#4 (review):

should cml ci run git config --global --add safe.directory .?

@casperdcl casperdcl added enhancement New feature or request cml-ci Subcommand labels Nov 4, 2022
@casperdcl
Copy link
Contributor Author

casperdcl commented Nov 4, 2022

Actually seems duplicate of #970 and related to #984 as well as iterative/cml.dev#385

@0x2b3bfa0
Copy link
Member

Unless proven otherwise, this functionality is already implemented for every cml command, including cml ci

cml/src/cml.js

Lines 84 to 121 in fc9e235

const fixGitSafeDirectory = () => {
const gitConfigSafeDirectory = (value) =>
spawnSync(
'git',
[
'config',
'--global',
value ? '--add' : '--get-all',
'safe.directory',
value
],
{
encoding: 'utf8'
}
).stdout;
const addSafeDirectory = (directory) =>
gitConfigSafeDirectory()
.split(/[\r\n]+/)
.includes(directory) || gitConfigSafeDirectory(directory);
// Fix for git>=2.36.0
addSafeDirectory('*');
// Fix for git^2.35.2
addSafeDirectory('/');
for (
let root, dir = process.cwd();
root !== dir;
{ root, dir } = path.parse(dir)
) {
addSafeDirectory(dir);
}
};
class CML {
constructor(opts = {}) {
fixGitSafeDirectory(); // https://github.com/iterative/cml/issues/970

@0x2b3bfa0
Copy link
Member

Closed with #974

@0x2b3bfa0 0x2b3bfa0 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cml-ci Subcommand enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants