GetCurrentChanges() public method

public GetCurrentChanges ( string fileName, string oldFileName, bool staged, string extraDiffArguments, Encoding encoding ) : PatchApply.Patch
fileName string
oldFileName string
staged bool
extraDiffArguments string
encoding System.Text.Encoding
return PatchApply.Patch
        private static string GetChangedFileText(GitModule module, GitItemStatus file)
        {
            var changes = module.GetCurrentChanges(file.Name, file.OldName, file.IsStaged, "-U1000000", module.FilesEncoding);

            if (changes != null)
                return changes.Text;

            var content = module.GetFileContents(file);

            if (content != null)
                return content;

            return File.ReadAllText(Path.Combine(module.WorkingDir, file.Name));
        }
Exemplo n.º 2
0
        private static PatchApply.Patch GetItemPatch(GitModule module, GitItemStatus file,
            string firstRevision, string secondRevision, string diffArgs, Encoding encoding)
        {
            bool cacheResult = true;
            if (GitRevision.IsArtificial(firstRevision))
            {
                bool staged = firstRevision == GitRevision.IndexGuid;
                if (secondRevision == null || secondRevision == GitRevision.IndexGuid)
                {
                    return module.GetCurrentChanges(file.Name, file.OldName, staged,
                            diffArgs, encoding);
                }

                cacheResult = false;
                firstRevision = secondRevision;
                secondRevision = string.Empty;
                if (staged)
                    diffArgs = string.Join(" ", diffArgs, "--cached");
            }
            else if (secondRevision == null)
                secondRevision = firstRevision + "^";

            return module.GetSingleDiff(firstRevision, secondRevision, file.Name, file.OldName,
                    diffArgs, encoding, cacheResult);
        }
Exemplo n.º 3
0
 public static GitSubmoduleStatus GetCurrentSubmoduleChanges(GitModule module, string fileName, string oldFileName, bool staged)
 {
     PatchApply.Patch patch = module.GetCurrentChanges(fileName, oldFileName, staged, "", module.FilesEncoding);
     string text = patch != null ? patch.Text : "";
     return GetSubmoduleStatus(text);
 }
 public static GitSubmoduleStatus GetSubmoduleChanges(GitModule module, string fileName, string oldFileName, bool staged)
 {
     string text = module.GetCurrentChanges(fileName, oldFileName, staged, "", module.FilesEncoding);
     return GetSubmoduleStatus(text);
 }
        private static string GetChangedFileText (GitModule module, GitItemStatus file)
        {
            var changes = module.GetCurrentChanges(file.Name, file.OldName, file.IsStaged, "-U1000000", module.FilesEncoding);

            if (changes != null)
                return changes.Text;

            var content = module.GetFileContents(file);

            if (content != null)
                return content;

            // Try to read the contents of the file: if it cannot be read, skip the operation silently.
            try
            {
                return File.ReadAllText(Path.Combine(module.WorkingDir, file.Name));
            }
            catch
            {
                return "";
            }
        }