From 1b0a4fc4ab52b8526d6f5cd11c4ed63b5c182da9 Mon Sep 17 00:00:00 2001 From: Roman Bataev Date: Sun, 13 Aug 2023 09:57:37 -0400 Subject: [PATCH] Cleanup. --- std/git.joke | 23 +---------------------- std/git/a_git.go | 17 ----------------- std/git/a_git_slow_init.go | 32 ++++++++++++++++++++++++++------ std/git/git_native.go | 16 ---------------- 4 files changed, 27 insertions(+), 61 deletions(-) diff --git a/std/git.joke b/std/git.joke index 87ebd78c..9bb16a30 100644 --- a/std/git.joke +++ b/std/git.joke @@ -1,20 +1,5 @@ (ns ^{:go-imports [] - :doc "Provides API for accessing and manipulating git repositories. - - Example: - - user=> (def db (joker.bolt/open \"bolt.db\" 0600)) - #'user/db - user=> (joker.bolt/create-bucket db \"users\") - nil - user=> (def id (joker.bolt/next-sequence db \"users\")) - #'user/id - user=> id - 1 - user=> (joker.bolt/put db \"users\" (str id) (joker.json/write-string {:id id :name \"Joe Black\"})) - nil - user=> (joker.json/read-string (joker.bolt/get db \"users\" (str id))) - {\"id\" 1, \"name\" \"Joe Black\"}"} + :doc "Provides API for accessing and manipulating git repositories."} git) (defn ^GitRepo open @@ -87,12 +72,6 @@ :go "findObject(repo, hash)"} [^GitRepo repo ^String hash]) -(defn status - "Returns the working tree status." - {:added "1.3" - :go "status(repo)"} - [^GitRepo repo]) - (defn commit "Returns a commit with the given hash." {:added "1.3" diff --git a/std/git/a_git.go b/std/git/a_git.go index c210cef9..5ee91812 100644 --- a/std/git/a_git.go +++ b/std/git/a_git.go @@ -148,23 +148,6 @@ func __resolve_revision_(_args []Object) Object { return NIL } -var __status__P ProcFn = __status_ -var status_ Proc = Proc{Fn: __status__P, Name: "status_", Package: "std/git"} - -func __status_(_args []Object) Object { - _c := len(_args) - switch { - case _c == 1: - repo := ExtractGitRepo(_args, 0) - _res := status(repo) - return _res - - default: - PanicArity(_c) - } - return NIL -} - func Init() { InternsOrThunks() diff --git a/std/git/a_git_slow_init.go b/std/git/a_git_slow_init.go index 0f71c73d..76a7b5ef 100644 --- a/std/git/a_git_slow_init.go +++ b/std/git/a_git_slow_init.go @@ -47,7 +47,32 @@ func InternsOrThunks() { gitNamespace.InternVar("log", log_, MakeMeta( NewListFrom(NewVectorFrom(MakeSymbol("repo"), MakeSymbol("opts"))), - `Returns the commit history from the given opts.`, "1.3")) + `Returns the commit history from the given opts. + opts may have the following keys: + + :from - when the from option is set the log will only contain commits + reachable from it. If this option is not set, HEAD will be used as + the default from. + + :order - the default traversal algorithm is depth-first search. + Set order to :committer-time for ordering by committer time (more compatible with `+"`"+`git log`+"`"+`). + Set order to :bsf for breadth-first search + + :path-filter - filter commits based on the path of files that are updated. + Takes file path as argument and should return true if the file is desired. + It can be used to implement `+"`"+`git log -- `+"`"+`. + Either is a file path, or directory path, or a regexp of file/directory path. + + :all - pretend as if all the refs in refs/, along with HEAD, are listed on the command line as . + It is equivalent to running `+"`"+`git log --all`+"`"+`. + If set to true, the :from option will be ignored. + + :since - show commits more recent than a specific date. + It is equivalent to running `+"`"+`git log --since `+"`"+` or `+"`"+`git log --after `+"`"+`. + + :until - show commits older than a specific date. + It is equivalent to running `+"`"+`git log --until `+"`"+` or `+"`"+`git log --before `+"`"+`. +`, "1.3")) gitNamespace.InternVar("object", object_, MakeMeta( @@ -72,9 +97,4 @@ func InternsOrThunks() { `Resolves revision to corresponding hash. It will always resolve to a commit hash, not a tree or annotated tag.`, "1.3").Plus(MakeKeyword("tag"), String{S: "String"})) - gitNamespace.InternVar("status", status_, - MakeMeta( - NewListFrom(NewVectorFrom(MakeSymbol("repo"))), - `Returns the working tree status.`, "1.3")) - } diff --git a/std/git/git_native.go b/std/git/git_native.go index 213eba7c..777b2786 100644 --- a/std/git/git_native.go +++ b/std/git/git_native.go @@ -283,22 +283,6 @@ func findObject(repo *git.Repository, hash string) Map { return res } -func status(repo *git.Repository) Map { - workTree, err := repo.Worktree() - PanicOnErr(err) - st, err := workTree.Status() - PanicOnErr(err) - res := EmptyArrayMap() - for filename, filestatus := range st { - fileStatusMap := EmptyArrayMap() - fileStatusMap.Add(MakeKeyword("staging"), MakeChar(rune(filestatus.Staging))) - fileStatusMap.Add(MakeKeyword("worktree"), MakeChar(rune(filestatus.Worktree))) - fileStatusMap.Add(MakeKeyword("extra"), MakeString(filestatus.Extra)) - res.Add(MakeString(filename), fileStatusMap) - } - return res -} - func init() { gitRepoType = RegType("GitRepo", (*GitRepo)(nil), "Wraps git.Repository type") }