//
        // Create a review if the content only contains a single patch file
        //
        private static Content CreatePatchOnlyReview(string[] reviewContent, Logging logger)
        {
            // If we have more than one file, it can't be a patch file
            if (reviewContent.Length != 1)
            {
                logger.Log("Review content is >1 so it cannot be a patch file");
                return(null);
            }

            // Get the file, is it a patch or diff file?
            string fileToCheck = reviewContent[0];

            if (IsFilePatch(fileToCheck) == false)
            {
                logger.Log("Given path to review is not a patch file");
                return(null);
            }

            // It is a patch file, now we need to make sure it's not part of the
            // repository because otherwse we'd need to review that!
            if (Svn.IsPathTracked(fileToCheck) == true)
            {
                logger.Log("Given path is a patch file but it is under source control");
                return(null);
            }

            // This is a patch file that has been selected specifically to review the
            // content and is not part of the repository
            return(new Content(Source.Patch, fileToCheck, null));
        }
示例#2
0
        //
        // Parses the command line options
        //
        public static Result ParseCommands(string fileList, bool injectPaths, Logging logger)
        {
            logger.Log(@"Parsing the file list command");

            // Get the file
            if (File.Exists(fileList) == false)
            {
                logger.Log(@"Unable to find the file list command file - {0}", fileList);
                return(null);
            }

            string[] fileContent = File.ReadAllLines(fileList);
            if (fileContent.Length == 0)
            {
                logger.Log(@"The given file list contains no content - {0}", fileList);
                return(null);
            }

            // Handle any debug options
            fileContent = HandleDebugRequest(fileContent, injectPaths);

            // Track all our content
            List <string> validPaths   = new List <string>();
            List <string> invalidPaths = new List <string>();

            // Check they all exist, and check they all all SVN repositories
            foreach (string thisPath in fileContent)
            {
                // Even a string?
                if (string.IsNullOrWhiteSpace(thisPath) == true)
                {
                    continue;
                }

                // Does it exist
                if (File.Exists(thisPath) == false && Directory.Exists(thisPath) == false)
                {
                    logger.Log(@"* Invalid path found in file list - {0}", thisPath);
                    invalidPaths.Add(thisPath);
                    continue;
                }

                // SVN path
                if (Svn.IsPathTracked(thisPath) == false)
                {
                    logger.Log(@"* Invalid path found in file list - {0}", thisPath);
                    invalidPaths.Add(thisPath);
                    continue;
                }

                // It's fine
                logger.Log(@"* Using - {0}", thisPath);
                validPaths.Add(thisPath);
            }

            // Return our paths
            return(new Result(validPaths.ToArray(), invalidPaths.ToArray()));
        }