Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions ext/rugged/rugged_settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down Expand Up @@ -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");
}
Expand Down
22 changes: 22 additions & 0 deletions test/lib_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down