Skip to content
This repository has been archived by the owner on Dec 29, 2023. It is now read-only.

Commit

Permalink
Fix failure to start on version reading, if .git dir is missing or Gi…
Browse files Browse the repository at this point in the history
…tPython is not installed"
  • Loading branch information
srevinsaju committed Apr 13, 2020
1 parent a362167 commit a8da371
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions guiscrcpy/lib/ver.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@
"""


__version__ = '3.4-raw'
__version__ = '3.5-raw'
import logging
try:
import git
except ModuleNotFoundError:
logging.warning(
'GitPython not installed. Fallback to pip3 version reading')
except Exception as e:
logging.info(f'Reading version from pip. {e}')
git = None


Expand Down

4 comments on commit a8da371

@niess
Copy link
Contributor

@niess niess commented on a8da371 Apr 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @srevinsaju :) This did not solve version reading issue for me.

The problem actually occurs when running git in order to read the version from a non existent .git directory. However the current fix only checks if the GitPython module can be imported. So in the case where GitPython is available but there is not a .git directory the version reading still fails.

You could add right after something like:

if git and not os.path.exists('/path/to/.git'):
    git = None

@niess
Copy link
Contributor

@niess niess commented on a8da371 Apr 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmm, actually it would be better to add this check before importing GitPython. So you don't import this module if it is not needed, i.e. if there is not .git history.

@srevinsaju
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@niess. Thanks, I might be dumb. Yes, after logically thing about what you have told, my fix looks sick. I have pushed another fix: 6d62911, please let me know, if that works for you. I apologize. I am still a student coder lol.

@niess
Copy link
Contributor

@niess niess commented on a8da371 Apr 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@srevinsaju No worry. You are doing a great job :) The task is complex. The devil is in the details.

Please sign in to comment.