git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v4 03/22] git-p4: indent with 4-spaces

From
Joel Holdsworth <jholdsworth@nvidia.com>
Date
Feb 10, 2022, 16:46 UTC
Message-ID
<20220210164627.279520-4-jholdsworth@nvidia.com>
In-Reply-To
<20220210164627.279520-1-jholdsworth@nvidia.com>

PEP8 recommends that all code should be indented in 4-space units. This guideline is described here:

https://www.python.org/dev/peps/pep-0008/#indentation

Previously git-p4 had multiple cases where code was indented with a non-multiple of 4-spaces. This patch fixes each of these.

Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
---
 git-p4.py | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/git-p4.py b/git-p4.py
index aabf657a57..a9be9ab13c 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -877,12 +877,12 @@ def extractLogMessageFromGitCommit(commit):
     ## fixme: title is first line of commit, not 1st paragraph.
     foundTitle = False
     for log in read_pipe_lines(["git", "cat-file", "commit", commit]):
-       if not foundTitle:
-           if len(log) == 1:
-               foundTitle = True
-           continue
+        if not foundTitle:
+            if len(log) == 1:
+                foundTitle = True
+            continue
 
-       logMessage += log
+        logMessage += log
     return logMessage
 
 
@@ -1094,7 +1094,7 @@ def createOrUpdateBranchesFromOrigin(localRefPrefix = "refs/remotes/p4/", silent
 
 
 def originP4BranchesExist():
-        return gitBranchExists("origin") or gitBranchExists("origin/p4") or gitBranchExists("origin/p4/master")
+    return gitBranchExists("origin") or gitBranchExists("origin/p4") or gitBranchExists("origin/p4/master")
 
 
 def p4ParseNumericChangeRange(parts):
@@ -2116,7 +2116,7 @@ def applyCommit(self, id):
         submitTemplate = self.prepareLogMessage(template, logMessage, jobs)
 
         if self.preserveUser:
-           submitTemplate += "\n######## Actual user %s, modified after commit\n" % p4User
+            submitTemplate += "\n######## Actual user %s, modified after commit\n" % p4User
 
         if self.checkAuthorship and not self.p4UserIsMe(p4User):
             submitTemplate += "######## git author %s does not match your p4 account.\n" % gitEmail
@@ -2565,7 +2565,7 @@ def run(self, args):
 
         # exit with error unless everything applied perfectly
         if len(commits) != len(applied):
-                sys.exit(1)
+            sys.exit(1)
 
         return True
 
@@ -3401,7 +3401,7 @@ def guessProjectName(self):
                 p = p[:-1]
             p = p[p.strip().rfind("/") + 1:]
             if not p.endswith("/"):
-               p += "/"
+                p += "/"
             return p
 
     def getBranchMapping(self):
-- 
2.35.GIT
Previous: Joel HoldsworthNext: Joel Holdsworth
Message 4 of 31 in “git-p4: Various code tidy-ups”
  1. 00/22 git-p4: Various code tidy-upsJoel Holdsworth, Feb 10, 2022
  2. 01/22 git-p4: add blank lines between functions and class definitionsJoel Holdsworth, Feb 10, 2022
  3. 02/22 git-p4: remove unneeded semicolons from statementsJoel Holdsworth, Feb 10, 2022
  4. 03/22 git-p4: indent with 4-spacesJoel Holdsworth, Feb 10, 2022
  5. 05/22 git-p4: convert descriptive class and function comments into docstringsJoel Holdsworth, Feb 10, 2022
  6. 04/22 git-p4: improve consistency of docstring formattingJoel Holdsworth, Feb 10, 2022
  7. 06/22 git-p4: remove commented codeJoel Holdsworth, Feb 10, 2022
  8. 07/22 git-p4: sort and de-duplcate pylint disable listJoel Holdsworth, Feb 10, 2022
  9. 09/22 git-p4: remove spaces around default argumentsJoel Holdsworth, Feb 10, 2022
  10. 08/22 git-p4: remove padding from lists, tuples and function argumentsJoel Holdsworth, Feb 10, 2022
  11. 10/22 git-p4: removed brackets when assigning multiple return valuesJoel Holdsworth, Feb 10, 2022
  12. 12/22 git-p4: remove extraneous spaces before function argumentsJoel Holdsworth, Feb 10, 2022
  13. 11/22 git-p4: place a single space after every commaJoel Holdsworth, Feb 10, 2022
  14. 13/22 git-p4: remove redundant backslash-continuations inside bracketsJoel Holdsworth, Feb 10, 2022
  15. 14/22 git-p4: remove spaces between dictionary keys and colonsJoel Holdsworth, Feb 10, 2022
  16. 15/22 git-p4: ensure every comment has a single #Joel Holdsworth, Feb 10, 2022
  17. 16/22 git-p4: ensure there is a single space around all operatorsJoel Holdsworth, Feb 10, 2022
  18. 17/22 git-p4: normalize indentation of lines in conditionalsJoel Holdsworth, Feb 10, 2022
  19. 19/22 git-p4: only seperate code blocks by a single empty lineJoel Holdsworth, Feb 10, 2022
  20. 20/22 git-p4: move inline comments to line aboveJoel Holdsworth, Feb 10, 2022
  21. 22/22 git-p4: sort importsJoel Holdsworth, Feb 10, 2022
  22. 18/22 git-p4: compare to singletons with "is" and "is not"Joel Holdsworth, Feb 10, 2022
  23. 21/22 git-p4: seperate multiple statements onto seperate linesJoel Holdsworth, Feb 10, 2022
  24. Tao KlerksApr 2, 2022
  25. Tao KlerksApr 2, 2022
  26. Joel HoldsworthApr 4, 2022
  27. Tao KlerksApr 5, 2022
  28. Tao KlerksApr 5, 2022
  29. Joel HoldsworthApr 5, 2022
  30. Tao KlerksApr 5, 2022
  31. Tao KlerksApr 11, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.