Title: [171845] trunk/Tools
Revision
171845
Author
[email protected]
Date
2014-07-31 01:41:33 -0700 (Thu, 31 Jul 2014)

Log Message

[GTK] Do not include files that are not in git in the tarball
https://bugs.webkit.org/show_bug.cgi?id=134804

Reviewed by Philippe Normand.

Skip all files in the source tree that are not under version control
except for files added from the build dir like the documentation.

* gtk/make-dist.py:
(Directory.__init__): Initialize the list of files under control version.
(Directory.list_cms_files): Helper function to list all files
under the control version for the current source root.
(Directory.should_skip_file): Return True for files that are not
under control version only when the source root is also under
control version.
(Directory.get_files): Filter the files also using should_skip_file().

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (171844 => 171845)


--- trunk/Tools/ChangeLog	2014-07-31 07:36:44 UTC (rev 171844)
+++ trunk/Tools/ChangeLog	2014-07-31 08:41:33 UTC (rev 171845)
@@ -1,3 +1,22 @@
+2014-07-31  Carlos Garcia Campos  <[email protected]>
+
+        [GTK] Do not include files that are not in git in the tarball
+        https://bugs.webkit.org/show_bug.cgi?id=134804
+
+        Reviewed by Philippe Normand.
+
+        Skip all files in the source tree that are not under version control
+        except for files added from the build dir like the documentation.
+
+        * gtk/make-dist.py:
+        (Directory.__init__): Initialize the list of files under control version.
+        (Directory.list_cms_files): Helper function to list all files
+        under the control version for the current source root.
+        (Directory.should_skip_file): Return True for files that are not
+        under control version only when the source root is also under
+        control version.
+        (Directory.get_files): Filter the files also using should_skip_file().
+
 2014-07-29  David Farler  <[email protected]>
 
         iOS Simulator LayoutTestRelay

Modified: trunk/Tools/gtk/make-dist.py (171844 => 171845)


--- trunk/Tools/gtk/make-dist.py	2014-07-31 07:36:44 UTC (rev 171844)
+++ trunk/Tools/gtk/make-dist.py	2014-07-31 08:41:33 UTC (rev 171845)
@@ -81,6 +81,10 @@
         self.source_root = source_root
         self.tarball_root = tarball_root
 
+    def should_skip_file(self, path):
+        # Do not skip files explicitly added from the manifest.
+        return False
+
     def get_files(self):
         yield (self.source_root, self.tarball_root)
 
@@ -91,12 +95,25 @@
         self.tarball_root = tarball_root
         self.rules = Ruleset()
 
+        self.files_in_version_control = self.list_files_in_version_control()
+
     def add_rule(self, rule):
         self.rules.add_rule(rule)
 
     def get_tarball_path(self, filename):
         return filename.replace(self.source_root, self.tarball_root, 1)
 
+    def list_files_in_version_control(self):
+        # FIXME: Only git is supported for now.
+        p = subprocess.Popen(['git', 'ls-tree', '-r', '--name-only', 'HEAD', self.source_root], stdout=subprocess.PIPE)
+        out = p.communicate()[0]
+        if not out:
+            return []
+        return out.rstrip('\n').split('\n')
+
+    def should_skip_file(self, path):
+        return path not in self.files_in_version_control
+
     def get_files(self):
         for root, dirs, files in os.walk(self.source_root):
 
@@ -189,9 +206,18 @@
         elif parts[0] == "include" and len(parts) > 1:
             self.add_rule(Rule(Rule.Result.INCLUDE, self.resolve_variables(parts[1])))
 
+    def should_skip_file(self, directory, filename):
+        # Only allow files that are not in version control when they are explicitly included in the manifest from the build dir.
+        if filename.startswith(self.build_root):
+            return False
+
+        return directory.should_skip_file(filename)
+
     def get_files(self):
         for directory in self.directories:
             for file_tuple in directory.get_files():
+                if self.should_skip_file(directory, file_tuple[0]):
+                    continue
                 yield file_tuple
 
     def create_tarfile(self, output):
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to