Skip to content

Commit

Permalink
app: move the logic from winmain() into main()
Browse files Browse the repository at this point in the history
Remove the winmain() entry points in favor of having a single
shared entry point across the board. The git-bindir initialization
is skipped when running the git-cola command directly, so it is
better to consolidate that logic into main() so that we can run
it in all situations.

Signed-off-by: David Aguilar <davvid@gmail.com>
  • Loading branch information
davvid committed Sep 30, 2022
1 parent 7c0c01d commit 4726cd5
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 27 deletions.
14 changes: 6 additions & 8 deletions cola/app.py
Expand Up @@ -538,6 +538,12 @@ def startup_message():

def initialize():
"""System-level initialization"""
# We support ~/.config/git-cola/git-bindir on Windows for configuring
# a custom location for finding the "git" executable.
git_path = find_git()
if git_path:
prepend_path(git_path)

# The current directory may have been deleted while we are still
# in that directory. We rectify this situation by walking up the
# directory tree and retrying.
Expand Down Expand Up @@ -618,14 +624,6 @@ def set_view(self, view):
self.runtask = qtutils.RunTask(parent=view)


def winmain(main_fn, *argv):
"""Find Git and launch main(argv)"""
git_path = find_git()
if git_path:
prepend_path(git_path)
return main_fn(*argv)


def find_git():
"""Return the path of git.exe, or None if we can't find it."""
if not utils.is_win32():
Expand Down
7 changes: 1 addition & 6 deletions cola/dag.py
Expand Up @@ -13,14 +13,9 @@ def main(argv=None):
return args.func(args)


def winmain():
"""Windows git-dag entrypoint"""
return app.winmain(main)


def shortcut_launch():
"""Run git-dag from a Windows shortcut"""
return app.winmain(main, ['--prompt'])
return main(argv=['--prompt'])


def parse_args(argv=None):
Expand Down
6 changes: 1 addition & 5 deletions cola/main.py
Expand Up @@ -28,10 +28,6 @@ def main(argv=None):
return args.func(args)


def winmain():
return app.winmain(main)


def parse_args(argv):
parser = argparse.ArgumentParser()
# Newer versions of argparse (Python 3.6+) emit an error message for
Expand Down Expand Up @@ -710,4 +706,4 @@ def shortcut_launch():
argv = sys.argv[1:]
if not argv:
argv = ['cola', '--prompt']
return app.winmain(main, argv)
return main(argv=argv)
5 changes: 0 additions & 5 deletions cola/sequenceeditor.py
Expand Up @@ -62,11 +62,6 @@ def main():
return view.status


def winmain():
"""Windows git-cola-sequence-editor entrypoint"""
return app.winmain(main)


def stop(_context, _view):
"""All done, cleanup"""
QtCore.QThreadPool.globalInstance().waitForDone()
Expand Down
6 changes: 3 additions & 3 deletions pynsist.cfg
Expand Up @@ -23,15 +23,15 @@ icon=cola/icons/git-cola.ico
extra_preamble=contrib/win32/pynsist-preamble.py

[Command git-cola]
entry_point=cola.main:winmain
entry_point=cola.main:main
extra_preamble=contrib/win32/pynsist-preamble.py

[Command git-cola-sequence-editor]
entry_point=cola.sequenceeditor:winmain
entry_point=cola.sequenceeditor:main
extra_preamble=contrib/win32/pynsist-preamble.py

[Command git-dag]
entry_point=cola.dag:winmain
entry_point=cola.dag:main
extra_preamble=contrib/win32/pynsist-preamble.py

# To identify unused DLL files to exclude, we can use Process Explorer.
Expand Down

0 comments on commit 4726cd5

Please sign in to comment.