Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
paulfouquet committed Nov 14, 2024
1 parent cfbff10 commit 0531380
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions scripts/update_stac_dates.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import os

import git


def get_collection_from_commit(repo, commit_hash, collection_path):
return repo.git.show(f"{commit_hash}:{collection_path}")


def main():
github_url = "https://github.com/linz/imagery.git"
clone_path = "/tmp/repo/"
collection_path = "stac/gisborne/gisborne_2023-2024_0.2m/rgb/2193/collection.json"

if not os.path.exists(clone_path):
repo = git.Repo.clone_from(github_url, clone_path)
else:
repo = git.Repo(clone_path)
repo.remotes.origin.pull()

repo.git.checkout("master")
commits = list(repo.iter_commits("master"))

# initial_commit = commits[0]
for i in range(1, len(commits)):
current_commit = commits[i]
previous_commit = commits[i - 1]

current_collection = get_collection_from_commit(repo, current_commit.hexsha, collection_path)
previous_collection = get_collection_from_commit(repo, previous_commit.hexsha, collection_path)


if __name__ == "__main__":
main()

0 comments on commit 0531380

Please sign in to comment.