]>
git.proxmox.com Git - libgit2.git/blob - tests/filter/ident.c
1 #include "clar_libgit2.h"
2 #include "git2/sys/filter.h"
4 static git_repository
* g_repo
= NULL
;
6 void test_filter_ident__initialize ( void )
8 g_repo
= cl_git_sandbox_init ( "crlf" );
11 void test_filter_ident__cleanup ( void )
13 cl_git_sandbox_cleanup ();
16 static void add_blob_and_filter (
25 cl_git_mkfile ( "crlf/identtest" , data
);
26 cl_git_pass ( git_blob_create_from_workdir (& id
, g_repo
, "identtest" ));
27 cl_git_pass ( git_blob_lookup (& blob
, g_repo
, & id
));
29 cl_git_pass ( git_filter_list_apply_to_blob (& out
, fl
, blob
));
31 cl_assert_equal_s ( expected
, out
. ptr
);
34 git_buf_dispose (& out
);
37 void test_filter_ident__to_worktree ( void )
42 cl_git_pass ( git_filter_list_new (
43 & fl
, g_repo
, GIT_FILTER_TO_WORKTREE
, 0 ));
45 ident
= git_filter_lookup ( GIT_FILTER_IDENT
);
46 cl_assert ( ident
!= NULL
);
48 cl_git_pass ( git_filter_list_push ( fl
, ident
, NULL
));
51 "Hello \n $Id$ \n Fun stuff \n " , fl
,
52 "Hello \n $Id: b69e2387aafcaf73c4de5b9ab59abe27fdadee30 $ \n Fun stuff \n " );
54 "Hello \n $Id: Junky$ \n Fun stuff \n " , fl
,
55 "Hello \n $Id: 45cd107a7102911cb2a7df08404674327fa050b9 $ \n Fun stuff \n " );
57 "$Id$ \n At the start \n " , fl
,
58 "$Id: b13415c767abc196fb95bd17070e8c1113e32160 $ \n At the start \n " );
60 "At the end \n $Id$" , fl
,
61 "At the end \n $Id: 1344925c6bc65b34c5a7b50f86bf688e48e9a272 $" );
64 "$Id: b3f5ebfb5843bc43ceecff6d4f26bb37c615beb1 $" );
66 "$Id: Some sort of junk goes here$" , fl
,
67 "$Id: ab2dd3853c7c9a4bff55aca2bea077a73c32ac06 $" );
69 add_blob_and_filter ( "$Id: " , fl
, "$Id: " );
70 add_blob_and_filter ( "$Id" , fl
, "$Id" );
71 add_blob_and_filter ( "$I" , fl
, "$I" );
72 add_blob_and_filter ( "Id$" , fl
, "Id$" );
74 git_filter_list_free ( fl
);
77 void test_filter_ident__to_odb ( void )
82 cl_git_pass ( git_filter_list_new (
83 & fl
, g_repo
, GIT_FILTER_TO_ODB
, 0 ));
85 ident
= git_filter_lookup ( GIT_FILTER_IDENT
);
86 cl_assert ( ident
!= NULL
);
88 cl_git_pass ( git_filter_list_push ( fl
, ident
, NULL
));
91 "Hello \n $Id$ \n Fun stuff \n " ,
92 fl
, "Hello \n $Id$ \n Fun stuff \n " );
94 "Hello \n $Id: b69e2387aafcaf73c4de5b9ab59abe27fdadee30$ \n Fun stuff \n " ,
95 fl
, "Hello \n $Id$ \n Fun stuff \n " );
97 "Hello \n $Id: Any junk you may have left here$ \n Fun stuff \n " ,
98 fl
, "Hello \n $Id$ \n Fun stuff \n " );
100 "Hello \n $Id:$ \n Fun stuff \n " ,
101 fl
, "Hello \n $Id$ \n Fun stuff \n " );
103 "Hello \n $Id:x$ \n Fun stuff \n " ,
104 fl
, "Hello \n $Id$ \n Fun stuff \n " );
107 "$Id$ \n At the start \n " , fl
, "$Id$ \n At the start \n " );
109 "$Id: lots of random text that should be removed from here$ \n At the start \n " , fl
, "$Id$ \n At the start \n " );
111 "$Id: lots of random text that should not be removed without a terminator \n At the start \n " , fl
, "$Id: lots of random text that should not be removed without a terminator \n At the start \n " );
114 "At the end \n $Id$" , fl
, "At the end \n $Id$" );
116 "At the end \n $Id:$" , fl
, "At the end \n $Id$" );
118 "At the end \n $Id:asdfasdf$" , fl
, "At the end \n $Id$" );
120 "At the end \n $Id" , fl
, "At the end \n $Id" );
122 "At the end \n $IddI" , fl
, "At the end \n $IddI" );
124 add_blob_and_filter ( "$Id$" , fl
, "$Id$" );
125 add_blob_and_filter ( "$Id: any$" , fl
, "$Id$" );
126 add_blob_and_filter ( "$Id: any long stuff goes here you see$" , fl
, "$Id$" );
127 add_blob_and_filter ( "$Id: " , fl
, "$Id: " );
128 add_blob_and_filter ( "$Id" , fl
, "$Id" );
129 add_blob_and_filter ( "$I" , fl
, "$I" );
130 add_blob_and_filter ( "Id$" , fl
, "Id$" );
132 git_filter_list_free ( fl
);