mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-05-19 21:28:37 +01:00
9f124e5b14
* Initial * Remove corrupt dmis * Fixup maps in TGM format4e5a32721f: maps/_templates_and_guidance/Public Event Templates/Maze_Reward_-_Copy.dmm4e5a32721f: maps/_templates_and_guidance/Templates/shelter_Medical.dmm4e5a32721f: maps/expedition_vr/aerostat/aerostat.dmm4e5a32721f: maps/expedition_vr/aerostat/aerostat_science_outpost.dmm4e5a32721f: maps/expedition_vr/beach/submaps/deadBeacon.dmm4e5a32721f: maps/expedition_vr/wild/tether_wild-crash-alt.dmm4e5a32721f: maps/expedition_vr/wild/tether_wild-crash.dmm4e5a32721f: maps/expedition_vr/wild/tether_wild-surface.dmm4e5a32721f: maps/expedition_vr/wild/tether_wild-temple.dmm4e5a32721f: maps/gateway_vr/lucky_7.dmm4e5a32721f: maps/gateway_vr/snow_outpost.dmm4e5a32721f: maps/overmap/_map.dmm4e5a32721f: maps/overmap/bearcat/bearcat.dmm4e5a32721f: maps/overmap/example_sector1.dmm4e5a32721f: maps/overmap/example_sector2.dmm4e5a32721f: maps/redgate/falls/falls.dmm4e5a32721f: maps/submaps/pois_vr/aerostat/CaveS.dmm4e5a32721f: maps/submaps/pois_vr/aerostat/DeadSettlers1.dmm4e5a32721f: maps/submaps/pois_vr/aerostat/DeadSettlers2.dmm4e5a32721f: maps/submaps/pois_vr/aerostat/DoomP.dmm4e5a32721f: maps/submaps/pois_vr/aerostat/Lab1.dmm4e5a32721f: maps/submaps/pois_vr/aerostat/Rockybase.dmm4e5a32721f: maps/submaps/pois_vr/debris_field/debris14.dmm4e5a32721f: maps/submaps/pois_vr/debris_field/derelict.dmm4e5a32721f: maps/submaps/pois_vr/debris_field/new_escapepod_xeno.dmm4e5a32721f: maps/submaps/surface_submaps/mountains/BlastMine1.dmm4e5a32721f: maps/submaps/surface_submaps/mountains/CaveTrench.dmm4e5a32721f: maps/submaps/surface_submaps/mountains/Cavelake.dmm4e5a32721f: maps/submaps/surface_submaps/mountains/Cliff1.dmm4e5a32721f: maps/submaps/surface_submaps/mountains/CrashedMedShuttle1.dmm4e5a32721f: maps/submaps/surface_submaps/mountains/Geyser1.dmm4e5a32721f: maps/submaps/surface_submaps/mountains/Geyser2.dmm4e5a32721f: maps/submaps/surface_submaps/mountains/Geyser3.dmm4e5a32721f: maps/submaps/surface_submaps/mountains/Mineshaft1.dmm4e5a32721f: maps/submaps/surface_submaps/mountains/Scave1.dmm4e5a32721f: maps/submaps/surface_submaps/mountains/SupplyDrop1.dmm4e5a32721f: maps/submaps/surface_submaps/mountains/crashed_ufo.dmm4e5a32721f: maps/submaps/surface_submaps/mountains/crashed_ufo_frigate.dmm4e5a32721f: maps/submaps/surface_submaps/mountains/crashedcontainmentshuttle.dmm4e5a32721f: maps/submaps/surface_submaps/mountains/crystal1.dmm4e5a32721f: maps/submaps/surface_submaps/mountains/crystal2.dmm4e5a32721f: maps/submaps/surface_submaps/mountains/crystal3.dmm4e5a32721f: maps/submaps/surface_submaps/mountains/deadBeacon.dmm4e5a32721f: maps/submaps/surface_submaps/mountains/deadly_rabbit_vr.dmm4e5a32721f: maps/submaps/surface_submaps/mountains/deadspy.dmm4e5a32721f: maps/submaps/surface_submaps/mountains/digsite.dmm4e5a32721f: maps/submaps/surface_submaps/mountains/excavation1.dmm4e5a32721f: maps/submaps/surface_submaps/mountains/lava_trench.dmm4e5a32721f: maps/submaps/surface_submaps/mountains/prepper1.dmm4e5a32721f: maps/submaps/surface_submaps/mountains/ritual.dmm4e5a32721f: maps/submaps/surface_submaps/mountains/spatial_anomaly.dmm4e5a32721f: maps/submaps/surface_submaps/mountains/speakeasy_vr.dmm4e5a32721f: maps/submaps/surface_submaps/mountains/vault1.dmm4e5a32721f: maps/submaps/surface_submaps/mountains/vault2.dmm4e5a32721f: maps/submaps/surface_submaps/mountains/vault3.dmm4e5a32721f: maps/submaps/surface_submaps/mountains/vault4.dmm4e5a32721f: maps/submaps/surface_submaps/mountains/vault5.dmm4e5a32721f: maps/submaps/surface_submaps/mountains/vault6.dmm4e5a32721f: maps/submaps/surface_submaps/plains/Boathouse.dmm4e5a32721f: maps/submaps/surface_submaps/plains/BuriedTreasure.dmm4e5a32721f: maps/submaps/surface_submaps/plains/BuriedTreasure2.dmm4e5a32721f: maps/submaps/surface_submaps/plains/BuriedTreasure3.dmm4e5a32721f: maps/submaps/surface_submaps/plains/Oldhouse.dmm4e5a32721f: maps/submaps/surface_submaps/plains/PooledR.dmm4e5a32721f: maps/submaps/surface_submaps/plains/Rocky5.dmm4e5a32721f: maps/submaps/surface_submaps/plains/Shakden.dmm4e5a32721f: maps/submaps/surface_submaps/plains/Thiefc.dmm4e5a32721f: maps/submaps/surface_submaps/plains/beacons.dmm4e5a32721f: maps/submaps/surface_submaps/plains/chemspill1.dmm4e5a32721f: maps/submaps/surface_submaps/plains/farm1.dmm4e5a32721f: maps/submaps/surface_submaps/plains/house1.dmm4e5a32721f: maps/submaps/surface_submaps/plains/lonehome.dmm4e5a32721f: maps/submaps/surface_submaps/plains/smol2.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/Blackshuttledown.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/Blueshuttledown.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/Boombase.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/CaveS.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/Chapel.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/Cragzone1.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/DJOutpost1.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/DJOutpost2.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/DJOutpost3.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/DJOutpost4.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/DecoupledEngine.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/DoomP.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/Drugden.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/Epod3.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/Epod4.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/Flake.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/FrostflyNest.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/MCamp1.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/MHR.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/Manor1.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/Mudpit.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/Rocky1.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/Rocky3.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/Rocky4.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/Rockybase.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/Shack1.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/Shelter.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/Smol1.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/Snowrock1.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/borglab.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/butchershack.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/chasm.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/chemspill2.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/deathden.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/derelictengine.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/frostoasis.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/kururakden.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/spider1.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/wolfden.dmm4e5a32721f: maps/submaps/surface_submaps/wilderness/xenohive.dmm4e5a32721f: maps/tether/tether-02-surface2.dmm4e5a32721f: maps/virgo_minitest/virgo_minitest-sector-2.dmm Automatically commited by: tools\mapmerge2\fixup.py * Remove unnecessary whitespace edits from mapmerger * Cable dirs update path * Fix area var edits * Put the area over there * Ignore archive maps folder * Forgot to port multivar support too * A few changes I forgot about for hook install * restore multivar support that chomp doesn't have yet * ban those * Forgot to add code for the marker too * Couple more of these invalid cables were added in master * Update multiple_blood_effects.yml * Update multiple_blood_effects.yml * Fixup maps in TGM format612ca9cbb9: maps/tether/submaps/tether_misc.dmm Automatically commited by: tools\mapmerge2\fixup.py * Fixup now logs the map its currently checking * Final fixes? * Fixup maps in TGM format3078e5cd0a: maps/expedition_vr/beach/submaps/crashedcontainmentshuttle.dmm3078e5cd0a: maps/redgate/fantasy_dungeon.dmm3078e5cd0a: maps/submaps/pois_vr/aerostat/Rockybase.dmm3078e5cd0a: maps/submaps/surface_submaps/mountains/crashedcontainmentshuttle_vr.dmm3078e5cd0a: maps/submaps/surface_submaps/plains/Oldhouse_vr.dmm3078e5cd0a: maps/submaps/surface_submaps/plains/dogbase.dmm3078e5cd0a: maps/submaps/surface_submaps/plains/greatwolfden.dmm3078e5cd0a: maps/submaps/surface_submaps/plains/lonehome_vr.dmm3078e5cd0a: maps/submaps/surface_submaps/plains/methlab.dmm3078e5cd0a: maps/submaps/surface_submaps/plains/oldhotel.dmm3078e5cd0a: maps/submaps/surface_submaps/plains/priderock.dmm3078e5cd0a: maps/submaps/surface_submaps/wilderness/Rockybase.dmm3078e5cd0a: maps/submaps/surface_submaps/wilderness/demonpool.dmm3078e5cd0a: maps/submaps/surface_submaps/wilderness/dogbase.dmm3078e5cd0a: maps/submaps/surface_submaps/wilderness/greatwolfden.dmm3078e5cd0a: maps/tether/submaps/underdark_pois/abandonded_outpost.dmm3078e5cd0a: maps/tether/submaps/underdark_pois/phoron_rat_den.dmm Automatically commited by: tools\mapmerge2\fixup.py * Fix tether_misc error * Remap reused solar farm area * Fix erroneous bearcat entries * Fix weird whitespace (most archive maps also affected but didn't bother) * misc mdb cleanup * moar * grr --------- Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com> Co-authored-by: Cameron Lennox <killer65311@gmail.com>
146 lines
5.5 KiB
Python
146 lines
5.5 KiB
Python
#!/usr/bin/env python3
|
|
import os
|
|
import pygit2
|
|
from . import dmm
|
|
from .mapmerge import merge_map, frontend
|
|
|
|
|
|
STATUS_INDEX = (pygit2.GIT_STATUS_INDEX_NEW
|
|
| pygit2.GIT_STATUS_INDEX_MODIFIED
|
|
| pygit2.GIT_STATUS_INDEX_DELETED
|
|
| pygit2.GIT_STATUS_INDEX_RENAMED
|
|
| pygit2.GIT_STATUS_INDEX_TYPECHANGE
|
|
)
|
|
STATUS_WT = (pygit2.GIT_STATUS_WT_NEW
|
|
| pygit2.GIT_STATUS_WT_MODIFIED
|
|
| pygit2.GIT_STATUS_WT_DELETED
|
|
| pygit2.GIT_STATUS_WT_RENAMED
|
|
| pygit2.GIT_STATUS_WT_TYPECHANGE
|
|
)
|
|
ABBREV_LEN = 12
|
|
TGM_HEADER = dmm.TGM_HEADER.encode(dmm.ENCODING)
|
|
|
|
|
|
def walk_tree(tree, *, _prefix=''):
|
|
for child in tree:
|
|
if isinstance(child, pygit2.Tree):
|
|
yield from walk_tree(child, _prefix=f'{_prefix}{child.name}/')
|
|
else:
|
|
yield f'{_prefix}{child.name}', child
|
|
|
|
|
|
def insert_into_tree(repo, tree_builder, path, blob_oid):
|
|
try:
|
|
first, rest = path.split('/', 1)
|
|
except ValueError:
|
|
tree_builder.insert(path, blob_oid, pygit2.GIT_FILEMODE_BLOB)
|
|
else:
|
|
inner = repo.TreeBuilder(tree_builder.get(first))
|
|
insert_into_tree(repo, inner, rest, blob_oid)
|
|
tree_builder.insert(first, inner.write(), pygit2.GIT_FILEMODE_TREE)
|
|
|
|
|
|
def main(repo : pygit2.Repository):
|
|
if repo.index.conflicts:
|
|
print("You need to resolve merge conflicts first.")
|
|
return 1
|
|
|
|
# Ensure the index is clean.
|
|
for path, status in repo.status().items():
|
|
if status & pygit2.GIT_STATUS_IGNORED:
|
|
continue
|
|
if status & STATUS_INDEX:
|
|
print("You have changes staged for commit. Commit them or unstage them first.")
|
|
print("If you are about to commit maps for the first time and can't use hooks, run `Run Before Committing.bat`.")
|
|
return 1
|
|
if path.endswith(".dmm") and (status & STATUS_WT):
|
|
print("You have modified maps. Commit them first.")
|
|
print("If you are about to commit maps for the first time and can't use hooks, run `Run Before Committing.bat`.")
|
|
return 1
|
|
|
|
# Set up upstream remote if needed
|
|
try:
|
|
repo.remotes.create("upstream", "https://github.com/VOREStation/VOREStation.git")
|
|
except ValueError:
|
|
pass
|
|
else:
|
|
print("Adding upstream remote...")
|
|
|
|
# Read the HEAD and ancestor commits.
|
|
head_commit = repo[repo.head.target]
|
|
repo.remotes["upstream"].fetch()
|
|
ancestor = repo.merge_base(repo.head.target, repo.revparse_single("refs/remotes/upstream/master").id)
|
|
if not ancestor:
|
|
print("Unable to automatically fix anything because merge base could not be determined.")
|
|
return 1
|
|
ancestor_commit = repo[ancestor]
|
|
print("Determined ancestor commit SHA to be:", ancestor)
|
|
|
|
# Walk the head commit tree and convert as needed
|
|
converted = {}
|
|
commit_message_lines = []
|
|
map_folder_to_check = os.path.join(frontend.read_settings().map_folder).replace("\\", "/").replace("../", "") # Remove this ever virgo maps aren't busted
|
|
for path, blob in walk_tree(head_commit.tree):
|
|
if path.endswith(".dmm") and path.startswith(map_folder_to_check):
|
|
print(f"Checking: {path}...")
|
|
head_data = blob.read_raw()
|
|
head_map = dmm.DMM.from_bytes(head_data)
|
|
|
|
# test: does every DMM convert cleanly (including TGM conversion)
|
|
try:
|
|
ancestor_blob = ancestor_commit.tree[path]
|
|
except KeyError:
|
|
# New map, no entry in ancestor
|
|
merged_map = merge_map(head_map, head_map)
|
|
merged_bytes = merged_map.to_bytes()
|
|
if head_data != merged_bytes:
|
|
print(f"Updating new map: {path}")
|
|
commit_message_lines.append(f"{'new':{ABBREV_LEN}}: {path}")
|
|
converted[path] = merged_map
|
|
else:
|
|
# Entry in ancestor
|
|
ancestor_map = dmm.DMM.from_bytes(ancestor_blob.read_raw())
|
|
merged_map = merge_map(head_map, ancestor_map)
|
|
merged_bytes = merged_map.to_bytes()
|
|
if head_data != merged_bytes:
|
|
print(f"Updating map: {path}")
|
|
str_id = str(ancestor_commit.id)[:ABBREV_LEN]
|
|
commit_message_lines.append(f"{str_id}: {path}")
|
|
converted[path] = merged_map
|
|
|
|
if not converted:
|
|
print("All committed maps appear to be okay.")
|
|
print("If you are about to commit maps for the first time and can't use hooks, run `Run Before Committing.bat`.")
|
|
return 1
|
|
|
|
# Okay, do the actual work.
|
|
tree_builder = repo.TreeBuilder(head_commit.tree)
|
|
for path, merged_map in converted.items():
|
|
blob_oid = repo.create_blob(merged_map.to_bytes())
|
|
insert_into_tree(repo, tree_builder, path, blob_oid)
|
|
repo.index.add(pygit2.IndexEntry(path, blob_oid, repo.index[path].mode))
|
|
merged_map.to_file(os.path.join(repo.workdir, path))
|
|
|
|
# Save the index.
|
|
repo.index.write()
|
|
|
|
# Commit the index to the current branch.
|
|
signature = pygit2.Signature(repo.config['user.name'], repo.config['user.email'])
|
|
joined = "\n".join(commit_message_lines)
|
|
repo.create_commit(
|
|
repo.head.name,
|
|
signature, # author
|
|
signature, # committer
|
|
f'Fixup maps in TGM format\n\n{joined}\n\nAutomatically commited by: {os.path.relpath(__file__, repo.workdir)}',
|
|
tree_builder.write(),
|
|
[head_commit.id],
|
|
)
|
|
|
|
# Success.
|
|
print("Successfully committed a fixup. Push as needed.")
|
|
return 0
|
|
|
|
|
|
if __name__ == '__main__':
|
|
exit(main(pygit2.Repository(pygit2.discover_repository(os.getcwd()))))
|