def _copy_versionned_to_area(self, source, dest_release, branch, do_version): """Source is a repo clone area dest_release is an existing direct to which the name of the repo name and the version will be copied under dest_release/tools_name/v?.?.? :paramsource: a valid git place (with a .git directory) :param dest_release :return ResultRepoInstall: """ # Check that source has all the criteria x = GitUtils(source) if not x.is_valid(): errors = ["Not a valid git:{}".format(source)] return ResultRepoInstall(False, errors, ['copy_versionned_to_area.source'], None) name = x.get_git_name() if name == "": errors = ["Not a valid name:{}".format(name)] return ResultRepoInstall(False, errors, ['copy_versionned_to_area.name'], None) atag = "" if do_version: atag = branch if branch == "": atag = x.get_git_version() if atag == "": errors = ["Not a valid tag:{}".format(atag)] return ResultRepoInstall(False, errors, ['copy_versionned_to_area.tag'], None) elif branch != "": # branch willbe in subdirectory atag = branch todolist = BaseFileProc() todolist.copy_folder_release(source, dest_release, name, atag) res = todolist.execute_stop_first_failed() if res.success == False: return ResultRepoInstall(False, res.errors, res.log, None) return ResultRepoInstall(True, res.errors, res.log, atag)
def test_version_when_tag_from_temp(): pytest.skip("test not multi-user friendly") RELEASE_LOCATION_DISK = '/mnt/dev/eric/packages' SRC_REPO = 'https://gitlab.com/erictexier/devsoftkit.git' try: from dsk.base.utils.git_utils import GitUtils except ImportError: print("needed: envi -p base_envi") sys.exit(0) tempdir = GitUtils.get_temp_git_clone_place_dir() x = GitUtils(tempdir) tempdest = x.get_temp_zone("REPO") res = x.clone_repo(SRC_REPO, tempdest) if res and len(res) > 0: if res[0] != "failed":# check x = GitUtils(tempdest) assert x.is_valid() print(x.get_git_version()) assert x.get_git_name() in SRC_REPO assert x.get_git_version().startswith("v") res = x.copy_versionned_to_area(tempdest, RELEASE_LOCATION_DISK) print(res) assert res.success == True
def test_version_when_tag(): x = GitUtils(DEV_ENV) tag = x.get_git_version() rootname = x.get_git_name() assert rootname != "" assert tag != ""
def test_git_name(): x = GitUtils(DEV_ENV) assert x.get_git_name() != ""