File tree Expand file tree Collapse file tree 3 files changed +60
-0
lines changed Expand file tree Collapse file tree 3 files changed +60
-0
lines changed Original file line number Diff line number Diff line change 4
4
[ ![ Dev] ( https://img.shields.io/badge/docs-dev-blue.svg )] ( https://JuliaVersionControl.github.io/GitRepl.jl/dev )
5
5
[ ![ Build Status] ( https://github.com/JuliaVersionControl/GitRepl.jl/workflows/CI/badge.svg )] ( https://github.com/JuliaVersionControl/GitRepl.jl/actions )
6
6
[ ![ Coverage] ( https://codecov.io/gh/JuliaVersionControl/GitRepl.jl/branch/master/graph/badge.svg )] ( https://codecov.io/gh/JuliaVersionControl/GitRepl.jl )
7
+
8
+ ## Git REPL mode
9
+
10
+ ``` julia
11
+ julia> using GitRepl
12
+
13
+ julia> gitrepl () # you only need to run this once per Julia session
14
+
15
+ # Press , to enter the Git REPL mode
16
+
17
+ git> clone https: // github. com/ JuliaRegistries/ General
18
+ ```
Original file line number Diff line number Diff line change @@ -3,4 +3,32 @@ module GitRepl
3
3
import GitCommand
4
4
import ReplMaker
5
5
6
+ export gitrepl
7
+
8
+ const GIT_REPL_MODE_NAME = " GitRepl.jl Git REPL mode"
9
+ const GIT_REPL_MODE_PROMPT_TEXT = " git> "
10
+ const GIT_REPL_MODE_START_KEY = ' ,'
11
+
12
+ function _gitrepl_parser (repl_input:: AbstractString )
13
+ return quote
14
+ repl_input = $ (Expr (:quote , repl_input))
15
+ run (` $(GitRepl. GitCommand. git ()) $(split (repl_input)) ` )
16
+ return nothing
17
+ end
18
+ end
19
+
20
+ function gitrepl (; mode_name = GIT_REPL_MODE_NAME,
21
+ prompt_text = GIT_REPL_MODE_PROMPT_TEXT,
22
+ start_key = GIT_REPL_MODE_START_KEY,
23
+ kwargs... )
24
+ ReplMaker. initrepl (
25
+ _gitrepl_parser;
26
+ mode_name = mode_name,
27
+ prompt_text = prompt_text,
28
+ start_key = start_key,
29
+ kwargs... ,
30
+ )
31
+ return nothing
32
+ end
33
+
6
34
end # module
Original file line number Diff line number Diff line change 1
1
using GitRepl
2
2
using Test
3
3
4
+ function withtempdir (f:: Function )
5
+ original_directory = pwd ()
6
+ mktempdir () do tmp_dir
7
+ return f (tmp_dir)
8
+ end
9
+ cd (original_directory)
10
+ return nothing
11
+ end
12
+
4
13
@testset " GitRepl.jl" begin
14
+ withtempdir () do tmp_dir
15
+ @test ! isdir (" GitRepl.jl" )
16
+ @test ! isfile (joinpath (" GitRepl.jl" , " Project.toml" ))
17
+ expr = GitRepl. _gitrepl_parser (" clone https://github.com/JuliaVersionControl/GitRepl.jl" )
18
+ @test expr isa Expr
19
+ @test ! isdir (" GitRepl.jl" )
20
+ @test ! isfile (joinpath (" GitRepl.jl" , " Project.toml" ))
21
+ @eval $ (expr)
22
+ @test isdir (" GitRepl.jl" )
23
+ @test isfile (joinpath (" GitRepl.jl" , " Project.toml" ))
24
+ end
5
25
end
You can’t perform that action at this time.
0 commit comments