Skip to content

Commit

Permalink
Cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
candid82 committed Aug 13, 2023
1 parent 2e957d1 commit 1b0a4fc
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 61 deletions.
23 changes: 1 addition & 22 deletions std/git.joke
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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"
Expand Down
17 changes: 0 additions & 17 deletions std/git/a_git.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
32 changes: 26 additions & 6 deletions std/git/a_git_slow_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 -- <path>`+"`"+`.
Either <path> 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 <commit>.
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 <date>`+"`"+` or `+"`"+`git log --after <date>`+"`"+`.
:until - show commits older than a specific date.
It is equivalent to running `+"`"+`git log --until <date>`+"`"+` or `+"`"+`git log --before <date>`+"`"+`.
`, "1.3"))

gitNamespace.InternVar("object", object_,
MakeMeta(
Expand All @@ -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"))

}
16 changes: 0 additions & 16 deletions std/git/git_native.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

0 comments on commit 1b0a4fc

Please sign in to comment.