File tree 4 files changed +42
-8
lines changed 4 files changed +42
-8
lines changed Original file line number Diff line number Diff line change @@ -177,12 +177,12 @@ module Consts
177
177
const RESET_HARD = Cint (3 ) # MIXED plus changes in working tree discarded
178
178
179
179
# rebase
180
- const REBASE_OPERATION_PICK = Cint (0 )
181
- const REBASE_OPERATION_REWORD = Cint (1 )
182
- const REBASE_OPERATION_EDIT = Cint (2 )
183
- const REBASE_OPERATION_SQUASH = Cint (3 )
184
- const REBASE_OPERATION_FIXUP = Cint (4 )
185
- const REBASE_OPERATION_EXEC = Cint (5 )
180
+ @enum (GIT_REBASE_OPERATION, REBASE_OPERATION_PICK = Cint (0 ),
181
+ REBASE_OPERATION_REWORD = Cint (1 ),
182
+ REBASE_OPERATION_EDIT = Cint (2 ),
183
+ REBASE_OPERATION_SQUASH = Cint (3 ),
184
+ REBASE_OPERATION_FIXUP = Cint (4 ),
185
+ REBASE_OPERATION_EXEC = Cint (5 ) )
186
186
187
187
# fetch_prune
188
188
const FETCH_PRUNE_UNSPECIFIED = Cint (0 )
Original file line number Diff line number Diff line change @@ -21,10 +21,12 @@ function current(rb::GitRebase)
21
21
end
22
22
23
23
function Base. getindex (rb:: GitRebase , i:: Integer )
24
+ if ! (1 <= i <= count (rb))
25
+ throw (BoundsError (rb, (i,)))
26
+ end
24
27
rb_op_ptr = ccall ((:git_rebase_operation_byindex , :libgit2 ),
25
28
Ptr{RebaseOperation},
26
29
(Ptr{Void}, Csize_t), rb. ptr, i- 1 )
27
- rb_op_ptr == C_NULL && return nothing
28
30
return unsafe_load (rb_op_ptr)
29
31
end
30
32
@@ -41,6 +43,11 @@ function Base.next(rb::GitRebase)
41
43
return unsafe_load (rb_op_ptr_ptr[])
42
44
end
43
45
46
+ function Base. show (io:: IO , rb:: GitRebase )
47
+ println (io, " GitRebase:" )
48
+ println (io, " Number: " , count (rb))
49
+ println (io, " Currently performing operation: " ,current (rb)+ 1 )
50
+ end
44
51
45
52
"""
46
53
LibGit2.commit(rb::GitRebase, sig::GitSignature)
Original file line number Diff line number Diff line change @@ -419,7 +419,10 @@ struct RebaseOperation
419
419
id:: GitHash
420
420
exec:: Cstring
421
421
end
422
- Base. show (io:: IO , rbo:: RebaseOperation ) = print (io, " RebaseOperation($(string (rbo. id)) )" )
422
+ function Base. show (io:: IO , rbo:: RebaseOperation )
423
+ println (io, " RebaseOperation($(string (rbo. id)) )" )
424
+ println (io, " Operation type: $(Consts. GIT_REBASE_OPERATION (rbo. optype)) " )
425
+ end
423
426
424
427
"""
425
428
LibGit2.StatusOptions
Original file line number Diff line number Diff line change @@ -842,6 +842,30 @@ mktempdir() do dir
842
842
843
843
newerhead = LibGit2. head_oid (repo)
844
844
@test newerhead == newhead
845
+
846
+ # add yet more files
847
+ open (joinpath (LibGit2. path (repo)," file5" )," w" ) do f
848
+ write (f, " 555\n " )
849
+ end
850
+ LibGit2. add! (repo, " file5" )
851
+ LibGit2. commit (repo, " add file5" )
852
+ open (joinpath (LibGit2. path (repo)," file6" )," w" ) do f
853
+ write (f, " 666\n " )
854
+ end
855
+ LibGit2. add! (repo, " file6" )
856
+ LibGit2. commit (repo, " add file6" )
857
+
858
+ # Rebase type
859
+ head_ann = LibGit2. GitAnnotated (repo, " branch/a" )
860
+ upst_ann = LibGit2. GitAnnotated (repo, " master" )
861
+ rb = LibGit2. GitRebase (repo, head_ann, upst_ann)
862
+ @test_throws BoundsError rb[3 ]
863
+ @test_throws BoundsError rb[0 ]
864
+ rbo = next (rb)
865
+ rbo_str = sprint (show, rbo)
866
+ @test rbo_str == " RebaseOperation($(string (rbo. id)) )\n Operation type: REBASE_OPERATION_PICK\n "
867
+ rb_str = sprint (show, rb)
868
+ @test rb_str == " GitRebase:\n Number: 2\n Currently performing operation: 1\n "
845
869
finally
846
870
close (repo)
847
871
end
You can’t perform that action at this time.
0 commit comments