diff --git a/info.rkt b/info.rkt index 1a87daa..443c51b 100644 --- a/info.rkt +++ b/info.rkt @@ -2,7 +2,7 @@ (define collection "git") (define pkg-desc "Command-line-like Git operations for Racket, implemented with libgit2") -(define version "0.2.10") +(define version "0.2.11") (define pkg-authors '("Hans Dijkema")) (define license 'MIT) diff --git a/main.rkt b/main.rkt index f7f5228..c78dd60 100644 --- a/main.rkt +++ b/main.rkt @@ -1,6 +1,8 @@ #lang racket/base (require ffi/unsafe + racket/runtime-path + setup/getinfo racket/async-channel racket/list racket/match @@ -11,6 +13,7 @@ (provide git dgit + git-version git-repository? git-root git-init @@ -27,11 +30,14 @@ git-commit git-head git-current-branch + git-switch git-branches + git-branch-create git-branch git-branch-delete git-checkout git-checkout-new + git-merge git-tags git-tag git-tag-delete @@ -58,6 +64,14 @@ (struct git-status-entry (path code flags) #:transparent) (struct git-log-entry (id summary time) #:transparent) +(define-runtime-path git-command-directory ".") + +(define (git-version) + (define info (get-info/full git-command-directory)) + (unless info + (error 'git-version "cannot read info.rkt")) + (info 'version (lambda () (error 'git-version "info.rkt has no version")))) + (define zero-oid-string (make-string GIT_OID_HEXSZ #\0)) (define branch-prefix "refs/heads/") (define tag-prefix "refs/tags/") @@ -66,6 +80,7 @@ (define GIT-CREDTYPE-USERNAME #x0020) (define GIT-PASSTHROUGH -30) (define GIT-CHECKOUT-OPTIONS-VERSION 1) +(define GIT-MERGE-OPTIONS-VERSION 1) (define (git-credential-callback out url username-from-url allowed-types _payload) ;; Never let a Racket exception escape through a C callback. In particular, @@ -550,18 +565,23 @@ #"") (sort branches string "0.2.11" +] + @section{Repository} @defproc[(git-repository? [path path-string? (current-directory)]) boolean?]{Returns whether @racket[path] is inside a Git repository.} @@ -60,7 +68,12 @@ Calls @racket[git], displays its result in a compact human-readable form, and re [(git-diff [option (or/c '--cached)]) string?])]{Returns a unified patch as a string. With no arguments it compares the index with the worktree, like @tt{git diff}. With @racket['--cached] it compares HEAD with the index, like @tt{git diff --cached}.} -@defproc[(git-add [path path-string?] ...) void?]{Stages the given paths. With no paths, stages the whole repository, including tracked removals.} +@defproc[(git-add [path path-string?] ...) void?]{Stages the given paths. With no paths, stages the whole repository, including tracked removals. The command form @racket[(git 'add '-A)] stages all current status entries, including new, modified, and removed paths.} + +@racketblock[ +(git 'add '-A) +(git 'commit "Update all changed files") +] @section{Configuration and commits} @@ -143,10 +156,12 @@ Remote HTTPS operations automatically use credentials from the @tt{racket-git} c The following command-like forms are supported directly: @racketblock[ +(git 'version) (git 'init) (git 'clone "https://example/repo.git") (git 'status) (git 'add "file.rkt") +(git 'add '-A) (git 'config "user.name" "Name") (git 'commit "message") (git 'branch-current) diff --git a/tests/branch-merge.rkt b/tests/branch-merge.rkt index c7fd24a..9c80f0c 100644 --- a/tests/branch-merge.rkt +++ b/tests/branch-merge.rkt @@ -4,6 +4,10 @@ racket/file git) + +(check-equal? (git 'version) "0.2.11") +(check-equal? (git-version) "0.2.11") + (define tmp (make-temporary-file "racket-git-branch-merge-test~a" 'directory)) (define (write-file path text)