Skip to content

Commit fb8d1f4

Browse files
committed
Fix 'git-obs pr dump' to skip the dump if the target has the same updated_at timestamp as the pull request in Gitea
1 parent 4170a3c commit fb8d1f4

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

osc/commands_git/pr_dump.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,17 @@ def run(self, args):
127127
# sanitize path for os.path.join()
128128
path = path.strip("/")
129129

130+
metadata_dir = os.path.join(path, "metadata")
131+
try:
132+
with open(os.path.join(metadata_dir, "pr.json")) as f:
133+
pr_data = json.load(f)
134+
if pr_data["updated_at"] == pr_obj.updated_at:
135+
# no update, skip the dump
136+
continue
137+
except FileNotFoundError:
138+
# no local metadata cached, we can't skip the dump
139+
pass
140+
130141
review_obj_list = pr_obj.get_reviews(self.gitea_conn)
131142

132143
# see https://github.com/go-gitea/gitea/blob/main/modules/structs/pull_review.go - look for "type ReviewStateType string"
@@ -238,7 +249,6 @@ def run(self, args):
238249
ET.Comment("The state='comment' attribute value is a custom extension to the OBS XML schema."),
239250
)
240251

241-
metadata_dir = os.path.join(path, "metadata")
242252
try:
243253
# remove old metadata first to ensure that we never keep any of the old files on an update
244254
shutil.rmtree(metadata_dir)

osc/gitea_api/pr.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ def body(self) -> str:
154154
def state(self) -> str:
155155
return self._data["state"]
156156

157+
@property
158+
def updated_at(self) -> str:
159+
return self._data["updated_at"]
160+
157161
@property
158162
def user(self) -> str:
159163
return self._data["user"]["login"]

0 commit comments

Comments
 (0)