Coverage for src / gitq / git_squash.py: 93%

23 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-04-15 15:32 -0400

1#!/usr/bin/env python3 

2 

3 

4import argparse 

5 

6from . import continuations 

7from .continuations import EditBranch 

8from .git_swap import edit_commit, OrSquash, Squash, Fixup 

9 

10description = """ 

11Combines COMMIT with COMMIT^. Opens an editor to compose the combined 

12commit message (like git commit --squash). 

13 

14With --fixup/-f, discards COMMIT's message and keeps only the parent's 

15(like git commit --fixup). 

16""" 

17 

18 

19class Main(continuations.Main): 

20 

21 tool = "git-squash" 

22 

23 def main(self): 

24 parser = argparse.ArgumentParser( 

25 description=description, formatter_class=argparse.RawDescriptionHelpFormatter 

26 ) 

27 parser.add_argument("commit", metavar="COMMIT") 

28 parser.add_argument("--fixup", "-f", action="store_true") 

29 args = parser.parse_args() 

30 

31 with self.setup(): 

32 commit = self.git.commit(args.commit) 

33 with EditBranch(message="git-squash"): 

34 with edit_commit(commit, git=self.git): 

35 with OrSquash(head=commit.sha, stop=False): 

36 if args.fixup: 

37 raise Fixup 

38 else: 

39 raise Squash 

40 

41 

42main = Main() 

43 

44if __name__ == "__main__": 44 ↛ 45line 44 didn't jump to line 45 because the condition on line 44 was never true

45 main()