{"id":15984141,"url":"https://github.com/aminya/globify_gitignore","last_synced_at":"2025-05-07T07:01:38.673Z","repository":{"id":46528999,"uuid":"414141203","full_name":"aminya/globify_gitignore","owner":"aminya","description":"Convert Gitignore to Glob patterns in Go","archived":false,"fork":false,"pushed_at":"2021-10-06T12:06:35.000Z","size":29,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-31T07:34:08.578Z","etag":null,"topics":["gitignore","glob","globify","globy","go","hacktoberfest","path"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aminya.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-06T09:04:42.000Z","updated_at":"2024-03-25T20:47:53.000Z","dependencies_parsed_at":"2022-07-19T22:18:06.185Z","dependency_job_id":null,"html_url":"https://github.com/aminya/globify_gitignore","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aminya%2Fglobify_gitignore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aminya%2Fglobify_gitignore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aminya%2Fglobify_gitignore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aminya%2Fglobify_gitignore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aminya","download_url":"https://codeload.github.com/aminya/globify_gitignore/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252831253,"owners_count":21810783,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gitignore","glob","globify","globy","go","hacktoberfest","path"],"created_at":"2024-10-08T02:04:38.433Z","updated_at":"2025-05-07T07:01:38.625Z","avatar_url":"https://github.com/aminya.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# globify-gitignore\n\nConvert Gitignore to Glob patterns\n\nA Go port of https://github.com/aminya/globify-gitignore\n\n## Usage\n\n\n```ts\nimport (\"github.com/aminya/globify_gitignore\")\n\nGlobifyGitIgnoreFile(\".\") // path to a directory that has a .gitignore\n```\n\nYou can use `globifyGitIgnore` to pass the gitignore content directly\n\n```ts\nimport (\"github.com/aminya/globify_gitignore\")\n\nfunc main() {\n  gitignoreContent := `# OS metadata\n  .DS_Store\n  Thumbs.db\n\n  # Node\n  node_modules\n  package-lock.json\n\n  # TypeScript\n  *.tsbuildinfo\n\n  # Build directories\n  dist\n  `\n  gitignoreDirectory = \"./\"\n\n  globPatterns = globifyGitIgnore(gitignoreContent, gitignoreDirectory)\n}\n```\n\n### API\n\nThese two functions are the main functions:\n\n```go\n/**\n * Parses and globifies the `.gitingore` file that exists in a directory\n *\n * @param {string} gitIgnoreDirectory The given directory that has the `.gitignore` file\n * @returns {([]string, error)} An array of glob patterns or an error if the file did not exist\n */\nfunc GlobifyGitIgnoreFile(gitIgnoreDirectory string) ([]string, error)\n\n/**\n * Globify the content of a `.gitignore` file\n *\n * @param {string} gitIgnoreContent The content of the gitignore file\n * @param {Optional string} gitIgnoreDirectory The directory of gitignore\n * @returns {[]string} An array of glob patterns\n */\nfunc GlobifyGitIgnore(\n\tgitIgnoreContent string,\n\tgitIgnoreDirectory ...string,\n) []string\n```\n\n### Other API\n\nOther possibly useful functions:\n\n```go\n/**\n * Globify a path\n * @param {string} givenPath The given path to be globified\n * @param {Optional string} givenDirectory [process.cwd()] The cwd to use to resolve relative path names\n * @returns {Promise\u003cstring | [string, string]\u003e} The glob path or the file path itself\n */\nfunc GlobifyPath(\n\tgivenPath string,\n\tgivenDirectory ...string,\n) []string\n\n\n/**\n * @param {string} gitIgnoreEntry One git ignore entry\n * @param {Optional string} gitIgnoreDirectory The directory of gitignore\n * @returns {[string] | [string, string]} The equivalent glob\n *\n * NOTE: it expects a **valid** non-comment git-ignore entry  with no surrounding whitespace.\n * NOTE: Gitignore expects that paths are posixified. So, if you are passing Windows path to this function directly without poxifying them (using {PosixifyPath}), you are passing invalid gitignore entry, and so you will get invalid Glob pattern.\n */\nfunc GlobifyGitIgnoreEntry(\n\tgitIgnoreEntry string,\n\tgitIgnoreDirectory ...string,\n) []string\n\n/**\n * Globifies a directory\n *\n * @param {string} givenDirectory The given directory to be globified\n */\nfunc GlobifyDirectory(givenDirectory string) string\n\n/// Is this string a valid path\nfunc IsPath(path string, extended bool) bool\n\n/// Is this string an invalid path?\nfunc IsInvalidPath(path string, extended bool) bool\n\n/**\n * Converts given path to Posix (replacing \\ with /)\n *\n * @param {string} givenPath Path to convert\n * @returns {string} Converted filepath\n */\nfunc PosixifyPath(givenPath string) string\n\n/**\n * Converts given path to Posix (replacing \\ with /)\n *\n * @param {string} givenPath Path to convert\n * @returns {string} Converted filepath\n */\nfunc PosixifyPath(givenPath string) string\n\n/**\n * Removes the ending slash from the given path\n *\n * @param {string} givenPath Path to convert\n * @returns {string} Converted filepath\n */\nfunc RemoveEndingSlash(givenPath string) string\n\n/**\n * A line starting with # serves as a comment. Put a backslash (\"\") in front of the first hash for patterns that begin\n * with a hash.\n */\nfunc IsGitIgnoreComment(pattern string) bool\n\n/** Trailing spaces should be removed unless they are quoted with backslash (\"\\ \"). */\nfunc TrimTrailingWhitespace(str string) string\n\n\n/** Remove leading whitespace */\nfunc TrimLeadingWhiteSpace(str string) string\n\n/** Remove whitespace from a gitignore entry */\nfunc TrimWhiteSpace(str string) string\n\n/**\n * Get the type of the given path\n *\n * @param {string} givenPath Absolute path\n * @returns {PathType}\n */\nfunc GetPathType(filepath string) PathType\n```\n\n## Contributing\n\n- Let me know if you encounter any bugs.\n- Feature requests are always welcome.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faminya%2Fglobify_gitignore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faminya%2Fglobify_gitignore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faminya%2Fglobify_gitignore/lists"}