Ejemplo n.º 1
0
        protected void OnHardLinkCreated(string relativeExistingFilePath, string relativeNewLinkPath)
        {
            try
            {
                if (!string.IsNullOrEmpty(relativeNewLinkPath))
                {
                    bool pathInDotGit = FileSystemCallbacks.IsPathInsideDotGit(relativeNewLinkPath);

                    if (pathInDotGit)
                    {
                        this.OnDotGitFileOrFolderChanged(relativeNewLinkPath);
                    }
                    else
                    {
                        this.FileSystemCallbacks.OnFileHardLinkCreated(relativeNewLinkPath);
                    }
                }
            }
            catch (Exception e)
            {
                EventMetadata metadata = this.CreateEventMetadata(relativeNewLinkPath, e);
                metadata.Add(nameof(relativeExistingFilePath), relativeExistingFilePath);
                this.LogUnhandledExceptionAndExit(nameof(this.OnHardLinkCreated), metadata);
            }
        }
Ejemplo n.º 2
0
        protected void OnFileRenamed(string relativeSourcePath, string relativeDestinationPath, bool isDirectory)
        {
            try
            {
                bool srcPathInDotGit = FileSystemCallbacks.IsPathInsideDotGit(relativeSourcePath);
                bool dstPathInDotGit = FileSystemCallbacks.IsPathInsideDotGit(relativeDestinationPath);

                if (dstPathInDotGit)
                {
                    this.OnDotGitFileOrFolderChanged(relativeDestinationPath);
                }

                if (!(srcPathInDotGit && dstPathInDotGit))
                {
                    if (isDirectory)
                    {
                        this.FileSystemCallbacks.OnFolderRenamed(relativeSourcePath, relativeDestinationPath);
                    }
                    else
                    {
                        this.FileSystemCallbacks.OnFileRenamed(relativeSourcePath, relativeDestinationPath);
                    }
                }
            }
            catch (Exception e)
            {
                EventMetadata metadata = this.CreateEventMetadata(relativeSourcePath, e);
                metadata.Add("destinationPath", relativeDestinationPath);
                metadata.Add("isDirectory", isDirectory);
                this.LogUnhandledExceptionAndExit(nameof(this.OnFileRenamed), metadata);
            }
        }
Ejemplo n.º 3
0
 public void IsPathInsideDotGitIsTrueForDotGitPath()
 {
     FileSystemCallbacks.IsPathInsideDotGit(@".git" + Path.DirectorySeparatorChar).ShouldEqual(true);
     FileSystemCallbacks.IsPathInsideDotGit(@".GIT" + Path.DirectorySeparatorChar).ShouldEqual(true);
     FileSystemCallbacks.IsPathInsideDotGit(Path.Combine(".git", "test_file.txt")).ShouldEqual(true);
     FileSystemCallbacks.IsPathInsideDotGit(Path.Combine(".GIT", "test_file.txt")).ShouldEqual(true);
     FileSystemCallbacks.IsPathInsideDotGit(Path.Combine(".git", "test_folder", "test_file.txt")).ShouldEqual(true);
     FileSystemCallbacks.IsPathInsideDotGit(Path.Combine(".GIT", "test_folder", "test_file.txt")).ShouldEqual(true);
 }
Ejemplo n.º 4
0
 public void IsPathInsideDotGitIsFalseForNonDotGitPath()
 {
     FileSystemCallbacks.IsPathInsideDotGit(@".git").ShouldEqual(false);
     FileSystemCallbacks.IsPathInsideDotGit(@".GIT").ShouldEqual(false);
     FileSystemCallbacks.IsPathInsideDotGit(@".gitattributes").ShouldEqual(false);
     FileSystemCallbacks.IsPathInsideDotGit(@".gitignore").ShouldEqual(false);
     FileSystemCallbacks.IsPathInsideDotGit(@".gitsubfolder\").ShouldEqual(false);
     FileSystemCallbacks.IsPathInsideDotGit(@".gitsubfolder\test_file.txt").ShouldEqual(false);
     FileSystemCallbacks.IsPathInsideDotGit(@"test_file.txt").ShouldEqual(false);
     FileSystemCallbacks.IsPathInsideDotGit(@"test_folder\test_file.txt").ShouldEqual(false);
 }
Ejemplo n.º 5
0
 public void EmptyStringIsNotInsideDotGitPath()
 {
     FileSystemCallbacks.IsPathInsideDotGit(string.Empty).ShouldEqual(false);
 }