Xgit v0.1.0 Xgit.Core.ValidatePath
Verifies that a path is an acceptable part of a tree structure.
Link to this section Summary
Functions
Check the provided path to see if it is a valid path within a git repository.
Check the provided path segment to see if it is a valid path within a git tree
object.
Return true
if the filename could be read as a .gitmodules
file when
checked out to the working directory.
Link to this section Types
result()
result() :: :ok | {:error, reason :: String.t()}
result() :: :ok | {:error, reason :: String.t()}
Response to validation functions in this module.
Link to this section Functions
check_path(path, opts \\ [])
Check the provided path to see if it is a valid path within a git repository.
The rules enforced here are slightly different from what is allowed in a tree
object in that we allow /
characters to build hierarchical paths.
Parameters
path
is a UTF-8 byte list containing the path to be tested.
Options
windows?
:true
to additionally verify that the path is permissible on Windows file systemsmacosx?
:true
to additionally verify that the path is permissible on Mac OS X file systems
Return Values
:ok
if the name is permissible given the constraints chosen above{:error, "reason"}
if the name is not permissible
check_path_segment(path, opts \\ [])
Check the provided path segment to see if it is a valid path within a git tree
object.
Parameters
path
is a UTF-8 byte list containing the path segment to be tested.
Options
windows?
:true
to additionally verify that the path is permissible on Windows file systemsmacosx?
:true
to additionally verify that the path is permissible on Mac OS X file systems
Return Values
:ok
if the name is permissible given the constraints chosen above{:error, "reason"}
if the name is not permissible
gitmodules?(path, opts \\ [])
Return true
if the filename could be read as a .gitmodules
file when
checked out to the working directory.
This would seem like a simple comparison, but some filesystems have peculiar rules for normalizing filenames:
NTFS has backward-compatibility support for 8.3 synonyms of long file names. (See https://web.archive.org/web/20160318181041/https://usn.pw/blog/gen/2015/06/09/filenames/ for details.) NTFS is also case-insensitive.
MacOS's HFS+ folds away ignorable Unicode characters in addition to case folding.
Parameters
path
is a UTF-8 byte list containing the path to be tested.
Options
By default, this function will only check for the plain .gitmodules
name.
windows?
:true
to additionally check for any path that might be treated as a.gitmodules
file on Windows file systemsmacosx?
:true
to additionally check for any path that might be treated as a.gitmodules
file on Mac OS X file systems