...
This commit is contained in:
@@ -105,20 +105,18 @@ pub fn get(args_ GitStructureArgGet) !&GitStructure {
|
||||
return gsinstances[rediskey_] or { panic('bug') }
|
||||
}
|
||||
|
||||
|
||||
@[params]
|
||||
pub struct GitPathGetArgs {
|
||||
pub mut:
|
||||
path string
|
||||
git_url string
|
||||
git_reset bool
|
||||
git_root string
|
||||
git_pull bool
|
||||
currentdir bool //can use currentdir
|
||||
path string
|
||||
git_url string
|
||||
git_reset bool
|
||||
git_root string
|
||||
git_pull bool
|
||||
currentdir bool // can use currentdir
|
||||
}
|
||||
|
||||
|
||||
//return pathlib Path based on, will pull...
|
||||
// return pathlib Path based on, will pull...
|
||||
// params:
|
||||
// path string
|
||||
// git_url string
|
||||
@@ -126,13 +124,13 @@ pub mut:
|
||||
// git_root string
|
||||
// git_pull bool
|
||||
pub fn path(args_ GitPathGetArgs) !pathlib.Path {
|
||||
mut args:= args_
|
||||
if args.path.trim_space() == '' && args.currentdir{
|
||||
mut args := args_
|
||||
if args.path.trim_space() == '' && args.currentdir {
|
||||
args.path = os.getwd()
|
||||
}
|
||||
|
||||
if args.git_url.len > 0 {
|
||||
mut gs := gittools.get(coderoot: args.git_root)!
|
||||
mut gs := get(coderoot: args.git_root)!
|
||||
mut repo := gs.get_repo(
|
||||
url: args.git_url
|
||||
pull: args.git_pull
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
module gittools
|
||||
|
||||
import os
|
||||
|
||||
import freeflowuniverse.herolib.core.pathlib
|
||||
|
||||
fn test_gitlocation_from_url() {
|
||||
|
||||
@@ -113,7 +113,7 @@ pub fn (mut gitstructure GitStructure) get_repo(args_ ReposGetArgs) !&GitRepo {
|
||||
return error('Found more than one repository for \n${args}\n${repos}')
|
||||
}
|
||||
|
||||
//the pull & reset was not used, now re-inserted
|
||||
// the pull & reset was not used, now re-inserted
|
||||
mut repo := repositories[0] or { panic('bug get_repo') }
|
||||
|
||||
if args.pull {
|
||||
|
||||
@@ -6,7 +6,7 @@ import os
|
||||
@[params]
|
||||
pub struct GitCloneArgs {
|
||||
pub mut:
|
||||
//only url needed because is a clone
|
||||
// only url needed because is a clone
|
||||
url string
|
||||
sshkey string
|
||||
}
|
||||
@@ -18,21 +18,19 @@ pub fn (mut gitstructure GitStructure) clone(args GitCloneArgs) !&GitRepo {
|
||||
}
|
||||
|
||||
console.print_header('Git clone from the URL: ${args.url}.')
|
||||
//gitlocatin comes just from the url, not from fs of whats already there
|
||||
// gitlocatin comes just from the url, not from fs of whats already there
|
||||
git_location := gitstructure.gitlocation_from_url(args.url)!
|
||||
|
||||
|
||||
mut repo := gitstructure.repo_new_from_gitlocation(git_location)!
|
||||
//TODO: this seems to be wrong, we should not set the url here
|
||||
// TODO: this seems to be wrong, we should not set the url here
|
||||
// repo.status_wanted.url = args.url
|
||||
// repo.status_wanted.branch = git_location.branch_or_tag
|
||||
|
||||
mut repopath := repo.patho()!
|
||||
if repopath.exists(){
|
||||
if repopath.exists() {
|
||||
return error("can't clone on existing path, came from url, path found is ${repopath.path}.\n")
|
||||
}
|
||||
|
||||
|
||||
if args.sshkey.len > 0 {
|
||||
repo.set_sshkey(args.sshkey)!
|
||||
}
|
||||
@@ -41,16 +39,14 @@ pub fn (mut gitstructure GitStructure) clone(args GitCloneArgs) !&GitRepo {
|
||||
|
||||
cfg := gitstructure.config()!
|
||||
|
||||
|
||||
mut extra := ''
|
||||
if cfg.light {
|
||||
extra = '--depth 1 --no-single-branch '
|
||||
}
|
||||
|
||||
//the url needs to be http if no agent, otherwise its ssh, the following code will do this
|
||||
// the url needs to be http if no agent, otherwise its ssh, the following code will do this
|
||||
mut cmd := 'cd ${parent_dir} && git clone ${extra} ${repo.get_repo_url_for_clone()!} ${repo.name}'
|
||||
|
||||
|
||||
mut sshkey_include := ''
|
||||
if cfg.ssh_key_path.len > 0 {
|
||||
sshkey_include = "GIT_SSH_COMMAND=\"ssh -i ${cfg.ssh_key_path}\" "
|
||||
|
||||
@@ -87,7 +87,7 @@ pub fn (mut repo GitRepo) get_parent_dir(args GetParentDir) !string {
|
||||
return parent_dir
|
||||
}
|
||||
|
||||
//DONT THINK ITS GOOD TO GIVE THE BRANCH
|
||||
// DONT THINK ITS GOOD TO GIVE THE BRANCH
|
||||
// @[params]
|
||||
// pub struct GetRepoUrlArgs {
|
||||
// pub mut:
|
||||
@@ -96,8 +96,7 @@ pub fn (mut repo GitRepo) get_parent_dir(args GetParentDir) !string {
|
||||
|
||||
// url_get returns the URL of a git address
|
||||
fn (self GitRepo) get_repo_url_for_clone() !string {
|
||||
|
||||
//WHY do we do following, now uncommented, the following code dispisses the ssh url part
|
||||
// WHY do we do following, now uncommented, the following code dispisses the ssh url part
|
||||
// url := self.status_wanted.url
|
||||
// if true{panic(url)}
|
||||
// if url.len != 0 {
|
||||
@@ -112,7 +111,6 @@ fn (self GitRepo) get_repo_url_for_clone() !string {
|
||||
} else {
|
||||
return self.get_http_url()!
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fn (self GitRepo) get_ssh_url() !string {
|
||||
|
||||
Reference in New Issue
Block a user