Skip to content

Commit

Permalink
Write directly to file objects when possible.
Browse files Browse the repository at this point in the history
Instead of decoding the stdout of subprocess.run and then doing our own
writes, just hand subprocess the file object and let it write directly.
  • Loading branch information
eli-schwartz committed Jun 19, 2018
1 parent f12dfc4 commit 586f29b
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions src/aurman/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1002,15 +1002,8 @@ def show_pkgbuild(self, noedit: bool = False, show_changes: bool = False,

# if last commit seen hash file does not exist - create
if not os.path.isfile(last_commit_hash_file):
empty_tree_hash = run(
["git", "hash-object", "-t", "tree", "/dev/null"],
stdout=PIPE,
stderr=DEVNULL,
universal_newlines=True
).stdout.strip()

with open(last_commit_hash_file, 'w') as f:
f.write(empty_tree_hash)
run(["git", "hash-object", "-t", "tree", "/dev/null"], stdout=f, stderr=DEVNULL)

current_commit_hash = run(
["git", "rev-parse", "HEAD"], stdout=PIPE, stderr=DEVNULL, cwd=package_dir, universal_newlines=True
Expand Down

0 comments on commit 586f29b

Please sign in to comment.