def install(self, release_top_location, branch="", do_version=False, new_version=False): """Clone an accessible remote git address to a top location by using name and tag to build the install area :param release_top_location: (str existing branch) :param branch: (str) an optional existing branch :param do_version: add a tag :param new_version: when do_version is incremental try incremenent :returns ResultRepoInstall: success errors log atag """ if not os.path.isdir(release_top_location): log.error("release area needs to exist, %s doen't" % release_top_location) return False tempdir = GitUtils.get_temp_git_clone_place_dir() x = GitUtils(tempdir) tempdest = x.get_temp_zone("REPO") res = "" try: #The repo gets clone in this function res = x.clone_repo(self.src_repo, tempdest, branch) except Exception as e: log.error(str(e)) return ResultRepoInstall(False, [str(e)], None) if isinstance(res, str): res = [res] for r in res: # most likely to belong to the output in case of failure if 'fatal' in r: return ResultRepoInstall(False, res, "") if new_version == True and do_version == True and branch == "": # query tag, increment pach tag, push tag self._push_new_version(tempdest) # copy the temp repo contain in the release area res = self._copy_versionned_to_area(tempdest, release_top_location, branch, do_version) return res
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