Skip to content

Commit

Permalink
follow-cvelist.py exit if git pull fails
Browse files Browse the repository at this point in the history
  • Loading branch information
oh2fih committed Aug 14, 2024
1 parent e44437c commit 09b7e93
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions bin/follow-cvelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,20 +165,23 @@ def monitor(self) -> None:
cursor = new_cursor

def pull(self) -> None:
"""Runs git pull"""
"""Runs git pull. Exits if it fails."""
result = subprocess.run(
["git", "pull"], stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
if self.args.verbose > 1:
result = subprocess.run(
["git", "pull"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT
)
print(
f"{time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime())} "
f"{result.stdout.decode('utf-8').strip()}",
file=sys.stderr,
)
else:
subprocess.call(
["git", "pull"], stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT
if result.returncode > 0:
print(
f"\n{result.stderr.decode('utf-8').strip()}\n{ANSI.code('red')}"
f"Manual intervention required; 'git pull' failed!{ANSI.code('end')}",
file=sys.stderr,
)
sys.exit(1)

def get_cursor(self, offset: int = 0) -> str:
"""Gets commit id at the offset from the current head"""
Expand Down

0 comments on commit 09b7e93

Please sign in to comment.