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

$mol_build added MAM_NO_PULL, back init existing not-git directory #736

Merged
merged 3 commits into from
Feb 8, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
26 changes: 18 additions & 8 deletions build/ensure/git/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,28 @@ namespace $ {
return this.is_git(path) || this.submodules().has(path)
}

protected override init_existing(dir: string) {
@ $mol_mem_key
protected branch_remote(dir: string) {
const repo = this.repo(dir)
if (! repo) return null
if (! repo) return 'master'

const res = this.$.$mol_run.spawn( { command: ['git', 'remote', 'show', repo.url ], dir } )

return res.stdout.toString().match( /HEAD branch: (.*?)\n/ )?.[1] ?? 'master'
}

protected override init_existing(dir: string) {
// Если вручную склонить ревизию hyoo/mol перед запуском билда,
// то hyoo надо проинициалзировать в соответствии с meta.ree
const repo = this.repo(dir)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я каждый раз спотыкаюсь. Что такое repo?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

url + branch репозитория взятый из meta.tre

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Из названия это не понятно.

if (! repo) throw new Error(`"${dir}" not a repo`)
const { url, branch } = repo
this.$.$mol_run.spawn( { command: ['git', 'init'], dir } )

this.$.$mol_log3_warn({
place: `${this}.init_existing()`,
message: 'directory exsists in meta.tree, but not an a git repository',
dir,
hint: `git pull ${url} ${branch ?? 'master'}`,
})
const branch_norm = branch ?? this.branch_remote(dir)

this.$.$mol_run.spawn( { command: [ 'git', 'remote', 'add', '--track', branch_norm, 'origin' , url ], dir } )
this.$.$mol_run.spawn( { command: [ 'git', 'pull', 'origin', branch_norm ], dir } )

return null
}
Expand Down
6 changes: 6 additions & 0 deletions build/ensure/vcs/vcs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,14 @@ namespace $ {
}
}

protected no_pull() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше использоваться позитивную логику вместо негативной, чтобы потом не ломать голову о двойное отрицание.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

переназвал pull_disable

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enabled..

return Boolean(this.$.$mol_env()['MAM_NO_PULL'])
}

@ $mol_mem_key
ensure( path : string ) {
if (this.no_pull()) return false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я правильно понимаю, что все включение этой опции отключит не только обновление, но и установку отсутствующих зависимостей?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

переделал, что б clone остался, если репы нет


const mod = $mol_file.absolute( path )

if( mod.exists()) {
Expand Down