diff options
author | 2024-05-27 22:34:38 -0400 | |
---|---|---|
committer | 2024-06-07 11:02:43 -0400 | |
commit | 345d92e0e17f0b179e5d27381cc2395786cdd856 (patch) | |
tree | 00af1dade80cf0e5dd3bcd80c7ac033a02c96270 | |
parent | bin/merge-driver-ekeyword: Store merged output in correct location (diff) | |
download | gentoolkit-345d92e0e17f0b179e5d27381cc2395786cdd856.tar.gz gentoolkit-345d92e0e17f0b179e5d27381cc2395786cdd856.tar.bz2 gentoolkit-345d92e0e17f0b179e5d27381cc2395786cdd856.zip |
bin/merge-driver-ekeyword: Don't sys.exit() from main()
Makes unit testing easier.
Signed-off-by: Matt Turner <mattst88@gentoo.org>
-rwxr-xr-x | bin/merge-driver-ekeyword | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/bin/merge-driver-ekeyword b/bin/merge-driver-ekeyword index 70c9b3a..9a7a666 100755 --- a/bin/merge-driver-ekeyword +++ b/bin/merge-driver-ekeyword @@ -113,7 +113,7 @@ def apply_keyword_changes(ebuild: str, pathname: str, def main(argv: Sequence[str]) -> int: if len(argv) != 5: - sys.exit(-1) + return -1 O = argv[1] # %O - filename of original A = argv[2] # %A - filename of our current version @@ -124,20 +124,20 @@ def main(argv: Sequence[str]) -> int: if changes := keyword_changes(O, B): # Apply %O -> %B changes to %A result = apply_keyword_changes(A, P, changes) - sys.exit(result) + return result # Get changes to KEYWORDS= from %O to %A elif changes := keyword_changes(O, A): # Apply %O -> %A changes to %B result = apply_keyword_changes(B, P, changes) # Merged file should be left in %A shutil.move(B, A) - sys.exit(result) + return result else: try: os.execlp("git", "git", "merge-file", "-L", "HEAD", "-L", "base", "-L", "ours", A, O, B) except OSError: - sys.exit(-1) + return -1 if __name__ == "__main__": - main(sys.argv) + sys.exit(main(sys.argv)) |