Skip to content

Commit

Permalink
Fail when git repository contains files supposed to be generated
Browse files Browse the repository at this point in the history
boo#1230469
  • Loading branch information
adrianschroeter committed Nov 11, 2024
1 parent 3709a0d commit c53aa1f
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions obs_scm_bridge
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ class ObsGit(object):
line = self.run_cmd(cmd, cwd=outdir, fatal="git rev-parse")
tstamp = line.rstrip()
infofile = os.path.join(outdir, '_scmsync.obsinfo')
if os.path.exists(infofile):
logging.error("ERROR: The _scmsync.obsinfo file must not be part of the git repository.")
sys.exit(1)
with open(infofile, "w") as obsinfo:
obsinfo.write("mtime: " + tstamp + "\n")
obsinfo.write("commit: " + commit + "\n")
Expand Down Expand Up @@ -382,6 +385,9 @@ class ObsGit(object):
def write_info_file(self, filename: str, info: str) -> None:
if not filename.startswith("/"):
filename = self.outdir + "/" + filename
if os.path.exists(filename):
logging.error(f"ERROR: The {filename} file must not be part of the git repository.")
sys.exit(1)
with open(filename, 'w') as infofile:
infofile.write(info + '\n')

Expand All @@ -402,15 +408,23 @@ class ObsGit(object):
return
if projectscmsync:
projecturlxml=f"""\n <url>{escape(projectscmsync)}</url>"""
with open(f"{self.outdir}/{name}.xml", 'w') as xmlfile:
filename = f"{self.outdir}/{name}.xml"
if os.path.exists(filename):
logging.error(f"ERROR: The {name}.xml file must not be part of the git repository.")
sys.exit(1)
with open(filename, 'w') as xmlfile:
xmlfile.write(f"""<package name="{escape(name)}">""")
if self.enforce_bcntsynctag:
xmlfile.write(f"""<bcntsynctag>{escape(name)}</bcntsynctag>{projecturlxml}""")
xmlfile.write(f"""<scmsync>{escape(url)}</scmsync>
</package>\n""")

def write_package_xml_local_link(self, target: str, name: str) -> None:
with open(f"{self.outdir}/{name}.xml", 'w') as xmlfile:
filename = f"{self.outdir}/{name}.xml"
if os.path.exists(filename):
logging.error(f"ERROR: The {name}.xml file must not be part of the git repository.")
sys.exit(1)
with open(filename, 'w') as xmlfile:
xmlfile.write(f"""<package name="{escape(name)}">""")
if self.enforce_bcntsynctag:
xmlfile.write(f"""<bcntsynctag>{escape(name)}</bcntsynctag>{projecturlxml}""")
Expand Down

0 comments on commit c53aa1f

Please sign in to comment.