skilleter-thingy 0.0.50__py3-none-any.whl → 0.0.51__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of skilleter-thingy might be problematic. Click here for more details.

@@ -515,6 +515,13 @@ def difftool(commit_1=None, commit_2=None, files=None, tool=None):
515
515
 
516
516
  ################################################################################
517
517
 
518
+ # Match 'git diff --numstat' output - first re splits into lines added, removed
519
+ # and name. Second one is used if a file has been renamed, to get the old and
520
+ # new name components.
521
+
522
+ _DIFF_OUTPUT_RE = re.compile(r'(-|\d+)\s+(-|\d+)\s+(.*)')
523
+ _DIFF_OUTPUT_RENAME_RE = re.compile('(.*)\{(.*) => (.*)\}(.*)')
524
+
518
525
  def commit_info(commit_1=None, commit_2=None, paths=None, diff_stats=False):
519
526
  """ Return details of changes either in single commit (defaulting to the most
520
527
  recent one) or between two commits, optionally restricted a path or paths
@@ -523,22 +530,30 @@ def commit_info(commit_1=None, commit_2=None, paths=None, diff_stats=False):
523
530
  """
524
531
 
525
532
  def parse_diff_output(result):
526
- """Extract current filename and lines added/deleted from output from git diff --numstat"""
533
+ """Extract previous and current filename (which may be the same) and lines added/deleted
534
+ from output from git diff --numstat"""
535
+
536
+ p = _DIFF_OUTPUT_RE.fullmatch(result)
527
537
 
528
- p = re.fullmatch(r'(-|\d+)\s+(-|\d+)\s+(.*)', result)
538
+ # Extract number of lines added/removed
529
539
 
530
540
  lines_ins = 0 if p.group(1) == '-' else int(p.group(1))
531
541
  lines_del = 0 if p.group(2) == '-' else int(p.group(2))
532
542
 
543
+ # Check for rename and get both old and new names
544
+
533
545
  if ' => ' in p.group(3):
534
- filepath = p.group(3).split('{')[0]
535
- filename = p.group(3).split(' => ')[1]
536
- filename = filename.replace('}', '')
537
- filename = os.path.join(filepath, filename)
546
+ q = _DIFF_OUTPUT_RENAME_RE.fullmatch(p.group(3))
547
+
548
+ if q:
549
+ old_filename = q.group(1) + q.group(2) + q.group(4)
550
+ new_filename = q.group(1) + q.group(3) + q.group(4)
551
+ else:
552
+ old_filename, new_filename = p.group(3).split(' => ')
538
553
  else:
539
- filename = p.group(3)
554
+ old_filename = new_filename = p.group(3)
540
555
 
541
- return filename, lines_ins, lines_del
556
+ return old_filename, new_filename, lines_ins, lines_del
542
557
 
543
558
  # Either get changes between the two commits, or changes in the specified commit
544
559
 
@@ -588,22 +603,23 @@ def commit_info(commit_1=None, commit_2=None, paths=None, diff_stats=False):
588
603
  results = git(['diff', '--numstat'] + params)
589
604
 
590
605
  for result in results:
591
- filename, lines_ins, lines_del = parse_diff_output(result)
606
+ old_filename, new_filename, lines_ins, lines_del = parse_diff_output(result)
592
607
 
593
- info[filename]['deleted'] = lines_del
594
- info[filename]['added'] = lines_ins
608
+ info[new_filename]['deleted'] = lines_del
609
+ info[new_filename]['added'] = lines_ins
595
610
 
596
611
  # Run git diff to get stats ignoring whitespace changes and add them
597
612
 
598
613
  results = git(['diff', '--numstat', '--ignore-all-space', '--ignore-blank-lines'] + params)
599
614
 
600
615
  for result in results:
601
- filename, lines_ins, lines_del = parse_diff_output(result)
616
+ old_filename, new_filename, lines_ins, lines_del = parse_diff_output(result)
602
617
 
603
- info[filename]['non-ws deleted'] = lines_del
604
- info[filename]['non-ws added'] = lines_ins
618
+ info[new_filename]['non-ws deleted'] = lines_del
619
+ info[new_filename]['non-ws added'] = lines_ins
605
620
 
606
621
  # Fill in the blanks - files
622
+
607
623
  for filename in info:
608
624
  if 'deleted' not in info[filename]:
609
625
  info[filename]['deleted'] = info[filename]['added'] = 0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: skilleter_thingy
3
- Version: 0.0.50
3
+ Version: 0.0.51
4
4
  Summary: A collection of useful utilities, mainly aimed at making Git more friendly
5
5
  Author-email: John Skilleter <john@skilleter.org.uk>
6
6
  Project-URL: Home, https://skilleter.org.uk
@@ -50,7 +50,7 @@ skilleter_thingy/thingy/dc_util.py,sha256=Df73imXhHx3HzcPHiRcHAoea0e3HURdLcrolUs
50
50
  skilleter_thingy/thingy/dircolors.py,sha256=5NbXMsGWdABLvvZfB70VPmN6N5HyyihfpgoQq1NRJbg,12264
51
51
  skilleter_thingy/thingy/docker.py,sha256=9EFatudoVPfB1UbDEtzdJDB3o6ToHiNHv8-oLsUeqiQ,2449
52
52
  skilleter_thingy/thingy/files.py,sha256=8wXUHEGALhHvYtJewjSNwHFw-hGHFYbWH9_40lJj5ZY,4257
53
- skilleter_thingy/thingy/git.py,sha256=9y58KhFx6t9nNyqMbixM5cl8LBcD2sdCh9UgyVPv4bo,38043
53
+ skilleter_thingy/thingy/git.py,sha256=e7CmcL4tV0CktA1tJD7ZeIaOGIT3l4egSha6uV9WChU,38678
54
54
  skilleter_thingy/thingy/git2.py,sha256=HdLar1rN5-Uop6GvoWM-NERDBOI7s93dC6Ry7iuEumA,35473
55
55
  skilleter_thingy/thingy/gitlab.py,sha256=uXAF918xnPk6qQyiwPQDbMZfqtJzhiRqDS7yEtJEIAg,6079
56
56
  skilleter_thingy/thingy/logger.py,sha256=xKgPAq8KGXmtaXIFjFs1AmZJXtYrXJn2sqL3oxHZjfQ,3107
@@ -61,9 +61,9 @@ skilleter_thingy/thingy/run.py,sha256=051lGahG4liYLckQFpmSaGuE9Chd-lFdmJO85LdmeX
61
61
  skilleter_thingy/thingy/tfm_pane.py,sha256=40DmQeLMEUPiKKIJkgN1MEpIen00V70I1HB7Q6git44,19814
62
62
  skilleter_thingy/thingy/tidy.py,sha256=0EVUP2XyUTtoIpqaDwvrHL58YxM4Elvu5MO1nzhwLG4,5854
63
63
  skilleter_thingy/thingy/venv_template.py,sha256=SsVNvSwojd8NnFeQaZPCRQYTNdwJRplpZpygbUEXRnY,1015
64
- skilleter_thingy-0.0.50.dist-info/LICENSE,sha256=ljOS4DjXvqEo5VzGfdaRwgRZPbNScGBmfwyC8PChvmQ,32422
65
- skilleter_thingy-0.0.50.dist-info/METADATA,sha256=itzZGWAuQ6uaklD1TJH1F75YFn0AQCmpv7clMQ6XHD8,5313
66
- skilleter_thingy-0.0.50.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
67
- skilleter_thingy-0.0.50.dist-info/entry_points.txt,sha256=IT6cZSbGHrd2UzIQbiMRotKiTJnYJBkESC4fAe8gjsE,2026
68
- skilleter_thingy-0.0.50.dist-info/top_level.txt,sha256=8-JhgToBBiWURunmvfpSxEvNkDHQQ7r25-aBXtZv61g,17
69
- skilleter_thingy-0.0.50.dist-info/RECORD,,
64
+ skilleter_thingy-0.0.51.dist-info/LICENSE,sha256=ljOS4DjXvqEo5VzGfdaRwgRZPbNScGBmfwyC8PChvmQ,32422
65
+ skilleter_thingy-0.0.51.dist-info/METADATA,sha256=89Er69r_bvFLY6i4G7cMqTTn-G9LiEq6HwjSHNqeKLo,5313
66
+ skilleter_thingy-0.0.51.dist-info/WHEEL,sha256=HiCZjzuy6Dw0hdX5R3LCFPDmFS4BWl8H-8W39XfmgX4,91
67
+ skilleter_thingy-0.0.51.dist-info/entry_points.txt,sha256=IT6cZSbGHrd2UzIQbiMRotKiTJnYJBkESC4fAe8gjsE,2026
68
+ skilleter_thingy-0.0.51.dist-info/top_level.txt,sha256=8-JhgToBBiWURunmvfpSxEvNkDHQQ7r25-aBXtZv61g,17
69
+ skilleter_thingy-0.0.51.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (72.1.0)
2
+ Generator: setuptools (72.2.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5