diff --git a/ext/rugged/rugged_settings.c b/ext/rugged/rugged_settings.c index abab82ded..d53953b5e 100644 --- a/ext/rugged/rugged_settings.c +++ b/ext/rugged/rugged_settings.c @@ -96,6 +96,20 @@ static VALUE rb_git_set_option(VALUE self, VALUE option, VALUE value) git_libgit2_opts(GIT_OPT_SET_OWNER_VALIDATION, validation); } + else if (strcmp(opt, "server_connect_timeout") == 0) { + int val; + Check_Type(value, T_FIXNUM); + val = NUM2INT(value); + git_libgit2_opts(GIT_OPT_SET_SERVER_CONNECT_TIMEOUT, val); + } + + else if (strcmp(opt, "server_timeout") == 0) { + int val; + Check_Type(value, T_FIXNUM); + val = NUM2INT(value); + git_libgit2_opts(GIT_OPT_SET_SERVER_TIMEOUT, val); + } + else { rb_raise(rb_eArgError, "Unknown option specified"); } @@ -146,6 +160,18 @@ static VALUE rb_git_get_option(VALUE self, VALUE option) return validation ? Qtrue : Qfalse; } + else if (strcmp(opt, "server_connect_timeout") == 0) { + int val; + git_libgit2_opts(GIT_OPT_GET_SERVER_CONNECT_TIMEOUT, &val); + return INT2NUM(val); + } + + else if (strcmp(opt, "server_timeout") == 0) { + int val; + git_libgit2_opts(GIT_OPT_GET_SERVER_TIMEOUT, &val); + return INT2NUM(val); + } + else { rb_raise(rb_eArgError, "Unknown option specified"); } diff --git a/test/lib_test.rb b/test/lib_test.rb index 34f128cc4..5c62ad1ef 100644 --- a/test/lib_test.rb +++ b/test/lib_test.rb @@ -54,6 +54,28 @@ def test_owner_validation end end + def test_server_connect_timeout + before = Rugged::Settings['server_connect_timeout'] + + begin + Rugged::Settings['server_connect_timeout'] = 300_000 + assert_equal 300_000, Rugged::Settings['server_connect_timeout'] + ensure + Rugged::Settings['server_connect_timeout'] = before + end + end + + def test_server_timeout + before = Rugged::Settings['server_timeout'] + + begin + Rugged::Settings['server_timeout'] = 300_000 + assert_equal 300_000, Rugged::Settings['server_timeout'] + ensure + Rugged::Settings['server_timeout'] = before + end + end + def test_search_path paths = [['search_path_global', '/tmp/global'], ['search_path_xdg', '/tmp/xdg'],