From 7dfe700b51a9c5d5711275534d2365394c386fba Mon Sep 17 00:00:00 2001 From: Stefan Zerkalica Date: Thu, 6 Feb 2025 19:00:40 +0300 Subject: [PATCH] $mol_build_ensure_git do not init existing directory as git --- build/ensure/git/git.ts | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/build/ensure/git/git.ts b/build/ensure/git/git.ts index 6e75a4dbf5..7de59470da 100644 --- a/build/ensure/git/git.ts +++ b/build/ensure/git/git.ts @@ -117,26 +117,18 @@ namespace $ { return this.is_git(path) || this.submodules().has(path) } - @ $mol_mem_key - protected branch_remote(dir: string) { - const repo = this.repo(dir) - 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) { const repo = this.repo(dir) - if (! repo) throw new Error(`"${dir}" not a repo`) - const { url, branch } = repo - this.$.$mol_run.spawn( { command: ['git', 'init'], dir } ) + if (! repo) return null - const branch_norm = branch ?? this.branch_remote(dir) + const { url, branch } = repo - 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 } ) + 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'}`, + }) return null }