refactor: Extract git repository management into a dedicated module

- Moved git repository handling logic from `gittools` to a new
  `gitresolver` module for better code organization and reusability.
- Created a `GitUrlResolver` interface to abstract git URL resolution.
- Implemented a `GitToolsResolver` struct to adapt the existing
  `gittools` functionality to the new interface.  This allows for
  future extensibility with different git repository management
  strategies.
- Improved error handling and added more informative error messages.
- Improved the structure of the `heroscript` by breaking down the
  actions into smaller, more manageable units.
This commit is contained in:
Mahmoud-Emad
2025-07-23 19:00:43 +03:00
parent 835556b223
commit 5cee9a4d5a
7 changed files with 156 additions and 39 deletions

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env -S v -n -w -cg -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
import freeflowuniverse.herolib.dev.gittools
import freeflowuniverse.herolib.develop.gittools
import os
heroscript := "
@@ -8,12 +8,39 @@ heroscript := "
!!git.define
coderoot:'/tmp/code' //when we overrule the location, the default is ~/code
light:true //depth of git clone is 1
log:true
log:true
debug:false //give more error reporting
offline:false //makes sure will not try to get to internet, but do all locally
ssh_key_path:'' //if a specific ssh key is needed
reload:false //if set then will remove cache and load full status, this is slow !
!!git.clone
url:'https://github.com/vlang/v.git'
light:true
recursive:false
!!git.clone
url:'https://github.com/freeflowuniverse/herolib.git'
light:true
recursive:false
!!git.list
filter:'' //list all repositories
status_update:false //don't check remote status (faster)
!!git.repo_action
action:'pull'
name:'v' //pull the V repository
error_ignore:true //ignore errors if repo doesn't exist
!!git.repo_action
action:'pull'
name:'herolib' //pull the herolib repository
error_ignore:true //ignore errors if repo doesn't exist
!!git.list
filter:'' //list all repositories again to see updated status
status_update:true //check remote status this time
"
gittools.play(heroscript: heroscript)!