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 check mam submodule and do not init #727

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 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
43 changes: 36 additions & 7 deletions build/ensure/git/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,49 @@ namespace $ {
return git_dir.exists() && git_dir.type() === 'dir'
}

@ $mol_mem
protected submodules() {
const dir = this.root().path()
if (! this.is_git( dir ) ) return new Set<string>()

const command = 'git submodule status --recursive'
const output = this.$.$mol_run.spawn({ command, dir }).stdout.toString().trim()
@ $mol_action
protected submodule_dirs(opts: { dir: string, recursive?: boolean }) {
const output = this.$.$mol_run.spawn({
command: ['git', 'submodule', 'status', ...( opts.recursive ? ['--recursive'] : [] ) ],
dir: opts.dir,
}).stdout.toString().trim()

const dirs = output
.split('\n')
.map( str => str.match( /^\s*[^ ]+\s+([^ ]*).*/ )?.[1]?.trim() )
.filter($mol_guard_defined)

return dirs
}

@ $mol_mem
protected root_is_submodule() {
const dir = this.root().path()
if (this.is_git(dir)) return false

const parent = this.root().parent().path()

try {
const dirs = this.submodule_dirs({ dir: parent })

return dirs.some(str => str && dir.endsWith('/' + str))
Copy link
Member

@nin-jin nin-jin Jan 16, 2025

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.

а как?

} catch (e) {
if ($mol_promise_like(e)) $mol_fail_hidden(e)
console.error(e)
Copy link
Member

Choose a reason for hiding this comment

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

А чего не $mol_fail_log?

return false
}
}

@ $mol_mem
protected submodules() {
const dir = this.root().path()
if (! this.is_git( dir ) ) return new Set<string>()

const dirs = this.submodule_dirs({ dir, recursive: true })
.map(str => `${dir}/${str}`)
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.

а зачем усложнять, тут же str - 100% кусок пути относительно dir

Copy link
Member

@nin-jin nin-jin Jan 16, 2025

Choose a reason for hiding this comment

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

dir.resolve(str)
Но я бы лучше сразу в submodule_dirs резолвил.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

как то это все усложняет код с виду, тогда надо dir передавать не строкой, а объектом, либо в submodule_dirs mol_file.absolute вызывать

либо вообще все на объекты переделывать, но мало где нужен именно $mol_file, со строкой проще отлаживать


if (this.root_is_submodule()) dirs.push(dir)

return new Set(dirs)
}

Expand Down
1 change: 1 addition & 0 deletions build/ensure/vcs/vcs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ namespace $ {
@ $mol_action
protected update_safe(dir: string) {
if (this.update_disabled) return false
if ( this.$.$mol_env()['MOL_BUILD_VSC_UPDATE_DISABLE'] ) 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.

Ну с докером по-другому не сделать воспроизводимых билдов, а все хотят docker compose up и получить на другой машине такой же билд, пусть отключат для CI, если очень надо.

Copy link
Member

@nin-jin nin-jin Jan 16, 2025

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.

это не будет работать, если одну строчку надо поправить, конфиг какой-нить, а все новое прилетит


try {
return this.$.$mol_file.unwatched(() => this.update(dir), dir)
Expand Down
Loading