private static async Task <string> GetChangedFileTextAsync(GitModule module, GitItemStatus file)
        {
            var changes = await module.GetCurrentChangesAsync(file.Name, file.OldName, file.Staged == StagedStatus.Index, "-U1000000")
                          .ConfigureAwait(false);

            if (changes is not null)
            {
                return(changes.Text);
            }

            var content = await module.GetFileContentsAsync(file).ConfigureAwaitRunInline();

            if (content is not null)
            {
                return(content);
            }

            // Try to read the contents of the file: if it cannot be read, skip the operation silently.
            try
            {
                using (var reader = File.OpenText(Path.Combine(module.WorkingDir, file.Name)))
                {
                    return(await reader.ReadToEndAsync());
                }
            }
            catch
            {
                return("");
            }
        }
Ejemplo n.º 2
0
        public static async Task <GitSubmoduleStatus> GetCurrentSubmoduleChangesAsync(GitModule module, string fileName, string oldFileName, bool staged, bool noLocks = false)
        {
            Patch patch = await module.GetCurrentChangesAsync(fileName, oldFileName, staged, "", noLocks : noLocks).ConfigureAwait(false);

            string text = patch != null ? patch.Text : "";

            return(ParseSubmoduleStatus(text, module, fileName));
        }
Ejemplo n.º 3
0
        public static async Task <GitSubmoduleStatus?> GetCurrentSubmoduleChangesAsync(GitModule module, string?fileName, string?oldFileName, bool staged, bool noLocks = false)
        {
            Patch?patch = await module.GetCurrentChangesAsync(fileName, oldFileName, staged, "", noLocks : noLocks).ConfigureAwait(false);

            return(ParseSubmodulePatchStatus(patch, module, fileName));
        }