[PATCH] D82707: [clang][docs] Remove untracked files from formatted status

Nathan James via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jun 28 02:15:06 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGabafb655c85d: [clang][docs] Remove untracked files from formatted status (authored by njames93).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82707/new/

https://reviews.llvm.org/D82707

Files:
  clang/docs/tools/generate_formatted_state.py


Index: clang/docs/tools/generate_formatted_state.py
===================================================================
--- clang/docs/tools/generate_formatted_state.py
+++ clang/docs/tools/generate_formatted_state.py
@@ -72,6 +72,8 @@
      - {style2}`{percent}%`
 """
 
+FNULL = open(os.devnull, 'w')
+
 with open(DOC_FILE, 'wb') as output:
     sha = get_git_revision_short_hash()
     today = datetime.now().strftime("%B %d, %Y %H:%M:%S")
@@ -85,14 +87,22 @@
         for subdir in subdirs:
             if any(sd == subdir for sd in skipped_dirs):
                 subdirs.remove(subdir)
+            else:
+                act_sub_dir = os.path.join(root, subdir)
+                # Check the git index to see if the directory contains tracked
+                # files. Reditect the output to a null descriptor as we aren't
+                # interested in it, just the return code.
+                git_check = subprocess.Popen(
+                    ["git", "ls-files", "--error-unmatch", act_sub_dir],
+                    stdout=FNULL,
+                    stderr=FNULL)
+                if git_check.wait() != 0:
+                    print("Skipping directory: ", act_sub_dir)
+                    subdirs.remove(subdir)
 
         path = os.path.relpath(root, TOP_DIR)
         path = path.replace('\\', '/')
 
-        head, _ = os.path.split(root)
-        while head:
-            head, _ = os.path.split(head)
-
         file_count = 0
         file_pass = 0
         file_fail = 0


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82707.273911.patch
Type: text/x-patch
Size: 1497 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200628/e8341c4f/attachment-0001.bin>


More information about the cfe-commits mailing list