aboutsummaryrefslogtreecommitdiff
path: root/lib/git/git.go
AgeCommit message (Collapse)Author
2026-01-14lib/git: pass "--" when running LogFollow commandShulhan
The "--" prevent ambiguous argument, to separate a path from revision. While at it, add more test case for LogFollow.
2026-01-13lib/git: add method LogFollowShulhan
The LogFollow method return history of single file `path`, following rename. This method accept second paramter "format", default to '%h,%at,%an,%ae,%s' which print short hash, author commit timestamp, author name, author email, and subject; respectively separated by comma.
2026-01-11lib/git: fix ignore pattern with single wildcard '*'Shulhan
Single wildcard should ignore everything inside it.
2026-01-06lib/git: implement Equaler interface on GitShulhan
The Equaler interface provide the method Equal that when implemented can be used to compare two instances of struct.
2026-01-06lib/git: add Git type with method IsIgnoredShulhan
The Git type is for working with single git repository. The [Git.IsIgnored] method is to check if the `path` is ignored by git. This is processed by matching it with all of the pattern in the ".gitignore" file from the path directory and its parent until the root of Git repository.
2025-01-23all: use for-range with numericShulhan
Go 1.22 now support for-range on numeric value.
2024-03-05all: comply with linter recommendations #3Shulhan
For HTTP server that use TLS, set the minimum TLS version and ReadHeaderTimeout to mitigate slowloris attack. For HTTP client or server that parameterize the use of InsecureSkipVerify, annotate the line with "nolint:gosec" to allow the code pass the check. Library that still use sha1, in example in DKIM and TOTP, skip the warnings by annotating the line with "nolint:gosec". A pointer variable now allocated their address before assigning its value. Any error that returned now wrapped using "%w". Also, replace error checking using [errors.Is] or [errors.As] instead of using equal or not-equal operators. In "lib/http", replace any usage of "math/rand" with "crypto/rand". Any call of [math/big.Rat.SetString] now annotated with "nolint:gosec" since its false positive, the issue has been fixed in Go >= 1.17.7. Any switch case that does not cover the rest of the possible values now handled by adding the cases or by replacing the "default" case with the rest of values.
2024-03-05all: comply with linter recommendations #2Shulhan
HTTP request now implicitly create request with context. Any false positive related to not closing HTTP response body has been annotated with "nolint:bodyclose". In the example code, use consistent "// Output:" comment format, by prefixing with single space. Any comment on code now also prefixing with single space. An error returned without variables now use [errors.New] instead of [fmt.Errorf]. Any error returned using [fmt.Errorf] now wrapped using "%w" instead of "%s". Also, replace error checking using [errors.Is] or [errors.As], instead of using equal/not-equal operator. Any statement like "x = x OP y" now replaced with "x OP= y". Also, swap statement is simplified using "x, y = y, x". Any switch statement with single case now replaced with if-condition. Any call to defer on function or program that call [os.Exit], now replaced by calling the deferred function directly. Any if-else condition now replaced with switch statement, if possible.
2024-03-02all: move the repository to "git.sr.ht/~shulhan/pakakeh.go"Shulhan
There are several reasons that why we move from github.com. First, related to the name of package. We accidentally name the package with "share" a common word in English that does not reflect the content of repository. By moving to other repository, we can rename it to better and unique name, in this "pakakeh.go". Pakakeh is Minang word for tools, and ".go" suffix indicate that the repository related to Go programming language. Second, supporting open source. The new repository is hosted under sourcehut.org, the founder is known to support open source, and all their services are licensed under AGPL, unlike GitHub that are closed sources. Third, regarding GitHub CoPilot. The GitHub Terms of Service [1], allow any public content that are hosted there granted them to parse the content. On one side, GitHub helps and flourish the open source, but on another side have an issues regarding scraping the copyleft license [2]. [1]: https://docs.github.com/en/site-policy/github-terms/github-terms-of-service#4-license-grant-to-us [2]: https://githubcopilotinvestigation.com
2023-09-09lib/git: replace lib/test/mock with bytes.BufferShulhan
This changes require changing the internal type of _stdout and _stderr from *os.File to io.Reader. The reason of replacing lib/test/mock is to minimize read/write to file, since mock.Stdin/Stderr is a temporary files.
2023-05-20all: remove any usage of debug.Value in all packagesShulhan
Using global debug value for all packages turns out is not a good idea.
2022-05-09all: reformat all codes using gofmt 1.19 (the Go tip)Shulhan
2020-06-06all: use default linter optionsShulhan
2019-06-14all: fix nolint formatShulhan
The valid syntax to suppress linter warnings is "//nolint:<name>" with no space between comment and "nolint" and between ":". Also, we move the placement of nolint directive to the top of statements for multiple nolint in the same scope. While at it, fix and supress some linter warnings.
2019-03-01all: fix warnings from linterShulhan
Most of the warnings caused by update to linter which cause global variables declared with grouping "( ... )" and that has been suppressed, are become false-positive again.
2018-11-30all: minimize and suppress linter warnings for global variablesShulhan
2018-11-30all: fix linter warnings on naked returnShulhan
2018-11-29lib/git: add "--force" option to fetch commandShulhan
Rarely, new references may have been replaced the old one, which cause the fetch command failed.
2018-11-29all: fix warning from lintersShulhan
2018-10-31lib/git: add function to fetch and list tagsShulhan
2018-09-29lib/git: combine "--tags" options with "--all" on FetchAllShulhan
2018-09-15lib/git: fetch tags when calling FetchAllShulhan
2018-09-14lib/git: add function to get list of remote branchesShulhan
2018-09-14lib/git: change ref parameter to remote name on CheckoutRevisionShulhan
Using default ref ("origin/master") will result inconsistent branch name if branch is not "master".
2018-09-14lib/git: return immediately if we can't found latest tag revisionShulhan
2018-09-14lib/git: add parameter "--quiet" only if debug value is zeroShulhan
2018-09-14lib/git: remove call to FetchAll when checking out revisionShulhan
Let the client handle fetch, to prevent calling double fetch by package and by user.
2018-09-14lib/git: replace local debug variable with package debugShulhan
2018-09-12lib/git: new package that wrap common git commands and parse git configShulhan
List of current git commands that are wrapped, - Setting HEAD to specific revision: "git checkout <revision>" - Cloning repository: "git clone <remoteURL>" - Fetch all changes from remote: "git fetch --all" - Get tag on revision: "git describe --tags --exact-match <revision>" - Get latest commit: "git rev-parse --short <ref>" - Get latest tag - Get latest version (combination of get latest commit and tag) - Log revisions: "git --no-pager log --oneline"