Skip to content

Commit

Permalink
formatting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
garyjg committed Jun 19, 2024
1 parent 8853355 commit 4297776
Showing 1 changed file with 27 additions and 25 deletions.
52 changes: 27 additions & 25 deletions eol_scons/gitinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""
GitInfo collects versioning and other metadata from a git repository.
The git information is based on the most recent annotated git tag
The git information is based on the most recent annotated git tag
that can be reached through 'git describe'. This is combined
with the number of commits since that tag to create a distinct
revision number which can be traced to a particular git commit.
Expand Down Expand Up @@ -55,6 +55,7 @@
# Set to 1 to enable debugging output
_debug = 0


# Debugging print
def pdebug(msg):
if _debug:
Expand All @@ -65,7 +66,7 @@ class GitInfo:
"""
Encapsulate the repository characteristics, making them available via a
dictionary.
Git commands used to extract the repository information:
git describe --match [vV][0-9]*:
Expand All @@ -76,18 +77,18 @@ class GitInfo:
number of commits since the tag. Third is the abbreviate object name of
the last commit. If the tag points to the most recent commit, then
commit is '0'.
git config --get remote.origin.url:
Get the repository URL that this branch was fetched from.
git log --pretty=format:"%cd,%H" -1:
git log --pretty=format:"%cd,%H" -1:
Get the date and hash of the last commit in a form easily split.
Wed Nov 26 16:42:30 2014 -0700,3189d8e443a6cf5827fc9617ebe8b95ab83d8eaf
git rev-parse --show-toplevel:
git rev-parse --show-toplevel:
Find the top of the working directory: /Users/martinc/git/aspen
Expand Down Expand Up @@ -144,8 +145,8 @@ class GitInfo:

gitcmd: str
match: str
repopath: Path or None
header: Path or None
repopath: Path
header: Path

def __init__(self, env=None, repopath=None):
"""
Expand Down Expand Up @@ -224,15 +225,15 @@ def _git_info(self):
error = []

# Use the collected git details to populate the dicitionary items
gitrevision = None
gitdate = None
giturl = None
gitworkdir = None
gittag = None
gitcommits = None
githash = None
gitbranch = None
gitdirty = None
gitrevision = None
gitdate = None
giturl = None
gitworkdir = None
gittag = None
gitcommits = None
githash = None
gitbranch = None
gitdirty = None

# Run git describe, and extract the tag, number of commits, and
# object name. Extract the hyphenated fields from right to left,
Expand Down Expand Up @@ -261,17 +262,18 @@ def _git_info(self):
gitdate, githash = cmd_out.split(',')

# Run git rev-parse to fetch the top level working directory
cmd_out = self._get_output([self.gitcmd, 'rev-parse', '--show-toplevel'])
cmd_out = self._get_output([self.gitcmd, 'rev-parse',
'--show-toplevel'])
if self._cmd_out_ok(cmd_out, error):
# Normalize path.
gitworkdir = cmd_out.replace('\\', '/').strip()

# Run git rev-parse to fetch the branch
cmd_out = self._get_output([self.gitcmd, 'rev-parse',
'--abbrev-ref', 'HEAD'])
if self._cmd_out_ok(cmd_out, error):
gitbranch = cmd_out.strip()

gitdirty = None
cmd_out = self._get_output([self.gitcmd, 'status', '--porcelain'])
if self._cmd_out_ok(cmd_out, error):
Expand Down Expand Up @@ -325,7 +327,7 @@ def getRepoInfo(self, repopath=None):

def applyToEnv(self, env):
"Apply the info values to the environment."
for k,v in self.values.items():
for k, v in self.values.items():
env[k] = v

def loadFromHeader(self, path):
Expand Down Expand Up @@ -358,8 +360,8 @@ def loadFromHeader(self, path):

def generateHeader(self):
"""
Create C text suitable for a header file, containing the revision attributes
included as defines.
Create C text suitable for a header file, containing the revision
attributes included as defines.
The self.values dictionary provide the attributes.
Expand All @@ -381,7 +383,7 @@ def generateHeader(self):
#endif
"""
repl = {k:("unknown" if v is None else v)
repl = {k: ("unknown" if v is None else v)
for k, v in self.values.items()}
githeader = githeader % repl
pdebug(githeader)
Expand Down

0 comments on commit 4297776

Please sign in to comment.