Class GitIgnoreZipper


  • public class GitIgnoreZipper
    extends Object
    Utility to recusively examine .gitignore files to determine what is not being stored in github repositories (e.g., customer data, certificates) and create an input file that zip can use to capture these files. An optional .overrides file can be used to keep .gitignored files from being added to the output file (e.g., zipper.files) to reduce the size of the resulting zip file.
    Author:
    wnm3
    • Constructor Detail

      • GitIgnoreZipper

        public GitIgnoreZipper()
    • Method Detail

      • main

        public static void main​(String[] args)
        Entry point to run this utility.
        Parameters:
        args - output file name (e.g., zipper.files), input directory (e.g., the directory to be searched recursively for .gitignore files to determine what has been left out of github repos to include in the output file, overrides file name (e.g., .overrides) listing directories and file names to be left out of the output file.
      • listFiles

        public List<Path> listFiles​(Path dir)
                             throws IOException
        Construct and return a sorted list of files in a directory identified by the dir
        Parameters:
        dir - the path to the directory containing files to be returned in the list
        Returns:
        sorted list of files in a directory identified by the dir
        Throws:
        IOException - if there is difficulty accessing the files in the supplied dir
      • listFiles

        public List<Path> listFiles​(Path dir,
                                    String ext)
                             throws IOException
        Construct and return a sorted list of files in a directory identified by the dir that have extensions matching the ext
        Parameters:
        dir - the path to the directory containing files to be returned in the list
        ext - the file extension (without the leading period) used to filter files in the dir. If ext is an empty string then all files are returned.
        Returns:
        sorted list of files in a directory identified by the dir that have extensions matching the ext
        Throws:
        IOException - if there is difficulty accessing the files in the supplied dir
      • listSubdirectories

        public List<Path> listSubdirectories​(Path dir)
                                      throws IOException
        Construct and return a sorted list of directories in a directory identified by the dir variable
        Parameters:
        dir - the path to the directory containing directories to be returned in the list
        Returns:
        sorted list of subdirectories in a directory identified by the dir
        Throws:
        IOException - if there is difficulty accessing the content in the supplied dir
      • loadTextFile

        public List<String> loadTextFile​(String fqFilename)
                                  throws Exception
        Reads the lines of a text file into a list of strings and returns that list. If no lines are present (e.g., empty file) then an empty list is returned.
        Parameters:
        fqFilename - fully qualified filename
        Returns:
        list of strings read from the file
        Throws:
        Exception - if the file can not be read.
      • prompt

        public String prompt​(String strPrompt)
        Print the supplied prompt (if not null) and return the trimmed response
        Parameters:
        strPrompt -
        Returns:
        the trimmed response to the prompt (may be the empty String ("") if nothing entered)
      • prompt

        public String prompt​(String strPrompt,
                             boolean bTrim)
        Print the supplied prompt (if not null) and return the trimmed response according to the supplied trim control
        Parameters:
        strPrompt -
        bTrim -
        Returns:
        the trimmed response (if so commanded) to the prompt (may be the empty String ("") if nothing entered)
      • saveTextFile

        public void saveTextFile​(String textFileName,
                                 String content)
                          throws Exception
        Save the specified JSONObject in serialized form to the specified file or throw the appropriate exception.
        Parameters:
        textFileName - fully qualified name of the JSON file to be saved
        content - the content to be saved to a file.
        Throws:
        Exception - IOException) if there is a problem writing the file