Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed git synchronization #1582

Merged
merged 4 commits into from
May 22, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed full COCO dataset import error with conflicting labels in keypoints and detection (https://github.com/opencv/cvat/pull/1548)
- Fixed COCO keypoints skeleton parsing and saving (https://github.com/opencv/cvat/issues/1539)
- `tf.placeholder() is not compatible with eager execution` exception for auto_segmentation (https://github.com/opencv/cvat/pull/1562)
- Synchronization with remote git repo (https://github.com/opencv/cvat/pull/1582)

### Security
-
Expand Down
17 changes: 8 additions & 9 deletions cvat/apps/git/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@
import shutil
import subprocess
from glob import glob
from tempfile import TemporaryDirectory
import zipfile

import django_rq
import git
from django.db import transaction
from django.utils import timezone
from pyunpack import Archive

from cvat.apps.dataset_manager.task import export_task
from cvat.apps.engine.log import slogger
Expand Down Expand Up @@ -284,16 +283,16 @@ def push(self, user, scheme, host, db_task, last_save):
if ext == '.zip':
shutil.move(dump_name, self._annotation_file)
elif ext == '.xml':
with TemporaryDirectory() as tmp_dir:
# TODO: remove extra packing-unpacking
Archive(src_path).extractall(tmp_dir)
anno_paths = glob(osp.join(tmp_dir, '**', '*.xml'),
recursive=True)
shutil.move(anno_paths[0], self._annotation_file)
with zipfile.ZipFile(dump_name) as archive:
for f in archive.namelist():
if f.endswith('.xml'):
with open(self._annotation_file, 'wb') as output:
output.write(archive.read(f))
break
os.remove(dump_name)
else:
raise Exception("Got unknown annotation file type")

os.remove(dump_name)
self._rep.git.add(self._annotation_file)

# Merge diffs
Expand Down