async def get_existing_problems(self) -> Set[Problem]: note_ref = '' result = set() if self.remote: fetch_notes = await asyncio.create_subprocess_exec( 'git', 'fetch', self.remote, '{0}:{0}'.format(NOTES_REF), **GIT_SUBPROCESS_KWARGS) await fetch_notes.wait() last_n_revisions_proc = await asyncio.create_subprocess_exec( 'git', 'log', '--skip=1', '-{}'.format(MAX_REVISIONS), '--pretty=%H', **GIT_SUBPROCESS_KWARGS) note_ref = self.get_note_ref(last_n_revisions_proc.stdout) await last_n_revisions_proc.wait() if note_ref: notes_proc = await asyncio.create_subprocess_exec( 'git', 'show', note_ref, **GIT_SUBPROCESS_KWARGS) async for line in notes_proc.stdout: try: problems = json.loads(line.decode()) for problem in problems: result.add(Problem.from_json(problem)) except Exception: pass await notes_proc.wait() return result
def get_existing_problems(self) -> Set[Problem]: note_ref = '' result = set() if self.remote: fetch_notes = yield from asyncio.create_subprocess_exec( 'git', 'fetch', self.remote, '{0}:{0}'.format(NOTES_REF), **GIT_SUBPROCESS_KWARGS) yield from fetch_notes.wait() last_n_revisions_proc = yield from asyncio.create_subprocess_exec( 'git', 'log', '--skip=1', '-{}'.format(MAX_REVISIONS), '--pretty=%H', **GIT_SUBPROCESS_KWARGS) for line in last_n_revisions_proc.stdout: notes_ref_proc = yield from asyncio.create_subprocess_exec( 'git', 'notes', 'list', line.decode().strip(), **GIT_SUBPROCESS_KWARGS) yield from notes_ref_proc.wait() if notes_ref_proc.returncode == 0: note_ref = yield from notes_ref_proc.stdout.readline() note_ref = note_ref.decode().strip() if note_ref: break yield from last_n_revisions_proc.wait() if note_ref: notes_proc = yield from asyncio.create_subprocess_exec( 'git', 'show', note_ref, **GIT_SUBPROCESS_KWARGS) for line in notes_proc.stdout: try: problems = json.loads(line.decode()) for problem in problems: result.add(Problem.from_json(problem)) except Exception: pass yield from notes_proc.wait() return result