Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package obs-scm-bridge for openSUSE:Factory checked in at 2022-06-08 14:25:14 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/obs-scm-bridge (Old) and /work/SRC/openSUSE:Factory/.obs-scm-bridge.new.1548 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "obs-scm-bridge" Wed Jun 8 14:25:14 2022 rev:2 rq:981289 version:0.2 Changes: -------- --- /work/SRC/openSUSE:Factory/obs-scm-bridge/obs-scm-bridge.changes 2022-02-17 23:41:51.255700255 +0100 +++ /work/SRC/openSUSE:Factory/.obs-scm-bridge.new.1548/obs-scm-bridge.changes 2022-06-08 14:25:33.916550276 +0200 @@ -1,0 +2,8 @@ +Wed Jun 8 09:55:31 UTC 2022 - Adrian Schr??ter <[email protected]> + +- update to version 0.2 + * no shallow clone when used with osc + * support for LFS fetch + * bugfixes (_config file export and path handling) + +------------------------------------------------------------------- Old: ---- obs-scm-bridge-0.1.obscpio New: ---- obs-scm-bridge-0.2.obscpio ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ obs-scm-bridge.spec ++++++ --- /var/tmp/diff_new_pack.nAP0rp/_old 2022-06-08 14:25:34.324550782 +0200 +++ /var/tmp/diff_new_pack.nAP0rp/_new 2022-06-08 14:25:34.328550786 +0200 @@ -23,7 +23,7 @@ %endif Name: obs-scm-bridge -Version: 0.1 +Version: 0.2 Release: 0 Summary: A help service to work with git repositories in OBS License: GPL-2.0-or-later ++++++ _service ++++++ --- /var/tmp/diff_new_pack.nAP0rp/_old 2022-06-08 14:25:34.356550822 +0200 +++ /var/tmp/diff_new_pack.nAP0rp/_new 2022-06-08 14:25:34.360550826 +0200 @@ -2,8 +2,8 @@ <service name="obs_scm" mode="manual"> <param name="url">https://github.com/openSUSE/obs-scm-bridge</param> <param name="scm">git</param> - <param name="revision">0.1</param> - <param name="version">0.1</param> + <param name="revision">0.2</param> + <param name="version">0.2</param> </service> <service mode="manual" name="set_version" /> ++++++ obs-scm-bridge-0.1.obscpio -> obs-scm-bridge-0.2.obscpio ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/obs-scm-bridge-0.1/obs_scm_bridge new/obs-scm-bridge-0.2/obs_scm_bridge --- old/obs-scm-bridge-0.1/obs_scm_bridge 2022-02-01 11:49:34.000000000 +0100 +++ new/obs-scm-bridge-0.2/obs_scm_bridge 2022-06-08 11:50:29.000000000 +0200 @@ -28,6 +28,7 @@ export_debian_orig_from_git = '/usr/lib/build/export_debian_orig_from_git' pack_directories = False get_assets = False +shallow_clone = True if os.environ.get('DEBUG_SCM_BRIDGE') == "1": logging.getLogger().setLevel(logging.DEBUG) @@ -36,6 +37,7 @@ get_assets = True if os.environ.get('OSC_VERSION'): get_assets = True + shallow_clone = False os.environ['LANG'] = "C" class ObsGit(object): @@ -43,6 +45,7 @@ self.outdir = outdir self.revision = None self.subdir = None + self.lfs = False self.arch = [] self.url = list(urllib.parse.urlparse(url)) query = urllib.parse.parse_qs(self.url[4]); @@ -54,6 +57,10 @@ self.arch = query['arch'] del query['arch'] self.url[4] = urllib.parse.urlencode(query) + if "lfs" in query: + self.lfs = True + del query['lfs'] + self.url[4] = urllib.parse.urlencode(query) if self.url[5]: self.revision = self.url[5] self.url[5] = '' @@ -77,24 +84,38 @@ sys.exit(proc.returncode) return (proc.returncode, output) + def do_lfs(self, outdir): + cmd = [ 'git', '-C', outdir, 'lfs', 'fetch' ] + self.run_cmd(cmd, fatal="git lfs fetch") + def do_clone_commit(self, outdir): cmd = [ 'git', 'init', outdir ] self.run_cmd(cmd, fatal="git init") cmd = [ 'git', '-C', outdir, 'remote', 'add', 'origin', urllib.parse.urlunparse(self.url) ] self.run_cmd(cmd, fatal="git remote add origin") - cmd = [ 'git', '-C', outdir, 'fetch', '--depth', '1', 'origin', self.revision ] + cmd = [ 'git', '-C', outdir, 'fetch', 'origin', self.revision ] + if shallow_clone: + cmd += [ '--depth', '1' ] + print(cmd) self.run_cmd(cmd, fatal="git fetch") cmd = [ 'git', '-C', outdir, 'checkout', '-q', self.revision ] self.run_cmd(cmd, fatal="git checkout") def do_clone(self, outdir): if self.revision and re.match(r"^[0-9a-fA-F]{40,}$", self.revision): - return self.do_clone_commit(outdir) - cmd = [ 'git', 'clone', '--depth', '1', urllib.parse.urlunparse(self.url), outdir ] + self.do_clone_commit(outdir) + if self.lfs: + self.do_lfs(outdir) + return + cmd = [ 'git', 'clone', urllib.parse.urlunparse(self.url), outdir ] + if shallow_clone: + cmd += [ '--depth', '1' ] if self.revision: cmd.insert(2, '-b') cmd.insert(3, self.revision) self.run_cmd(cmd, fatal="git clone") + if self.lfs: + self.do_lfs(outdir) def clone(self): if not self.subdir: @@ -103,6 +124,9 @@ clonedir = tempfile.mkdtemp(prefix="obs-scm-bridge") self.do_clone(clonedir) fromdir = os.path.join(clonedir, self.subdir) + if not os.path.realpath(fromdir+'/').startswith(os.path.realpath(clonedir+'/')): + print("ERROR: subdir is not below clone directory") + sys.exit(1) if not os.path.isdir(fromdir): print("ERROR: subdir " + self.subdir + " does not exist") sys.exit(1) @@ -222,16 +246,27 @@ xmlfile.write('</package>\n') xmlfile.close() + def list_submodule_revisions(self): + revisions = {} + cmd = [ 'git', 'ls-tree', 'HEAD', '.' ] + rcode, output = self.run_cmd(cmd, fatal="git ls-tree") + for line in output.splitlines(): + lstree = line.split(maxsplit=4) + if lstree[1] == 'commit' and len(lstree[2]) >= 40: + revisions[lstree[3]] = lstree[2] + return revisions + def generate_package_xml_files(self): logging.debug("walk via %s", self.outdir) os.chdir(self.outdir) - export_files = set("_config") + export_files = set(["_config"]) # find all top level git submodules gitsubmodules = set() if os.path.isfile('.gitmodules'): gsmconfig = configparser.ConfigParser() gsmconfig.read('.gitmodules') + revisions = None for section in gsmconfig.sections(): if not 'path' in gsmconfig[section]: logging.warn("path not defined for git submodule " + section) @@ -247,12 +282,11 @@ continue # find revision of submodule - cmd = [ 'git', 'ls-tree', 'HEAD', path ] - rcode, output = self.run_cmd(cmd, fatal="git ls-tree") - lstree = output.split() - revision = lstree[2] - if lstree[1] != 'commit' or len(revision) < 40: - logging.error("Invalid output of ls-tree for git submodule " + section) + if revisions is None: + revisions = self.list_submodule_revisions() + revision = revisions.get(path, None) + if not revision: + logging.error("Could not determine revision of submodule " + section) sys.exit(1) # all good, write xml file and register the module ++++++ obs-scm-bridge.obsinfo ++++++ --- /var/tmp/diff_new_pack.nAP0rp/_old 2022-06-08 14:25:34.476550970 +0200 +++ /var/tmp/diff_new_pack.nAP0rp/_new 2022-06-08 14:25:34.484550980 +0200 @@ -1,5 +1,5 @@ name: obs-scm-bridge -version: 0.1 -mtime: 1643712574 -commit: de4a9ad407efa69648e5451d85ff744a109900b8 +version: 0.2 +mtime: 1654681829 +commit: 67f17ebde3d22312d81a79c440337a75b704d360
