Skip to content

Commit 3e8759d

Browse files
committed
changed default behavior for parse repo url
1 parent 6109efd commit 3e8759d

3 files changed

Lines changed: 8 additions & 15 deletions

File tree

src/repo.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,6 @@ repository_t parse_repository(const char *line, ssize_t len, unsigned id)
149149
? empty_str()
150150
: str_init(bracket_open + 1, url_len);
151151

152-
if (repo.url.len != 0 && get_char(repo.url, repo.url.len - 1) != '/') {
153-
str_t postfix = str_init("/", 1);
154-
str_t new_url = str_concat(repo.url, postfix);
155-
str_free(repo.url);
156-
str_free(postfix);
157-
repo.url = new_url;
158-
}
159152
repo.format = (fmt_t) {
160153
.commit_url = select_function(repo.url),
161154
};

src/utils.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@
3535

3636
#define DEFAULT_EDITOR "vi"
3737

38-
#define GITHUB_URL "commit/"
39-
#define GITHUB_URL_SIZE 7
40-
#define GITLAB_URL "-/commit/"
41-
#define GITLAB_URL_SIZE 9
38+
#define GITHUB_URL "/commit/"
39+
#define GITHUB_URL_SIZE 8
40+
#define GITLAB_URL "/-/commit/"
41+
#define GITLAB_URL_SIZE 10
4242

4343
static str_t time_to_full_string(time_t timestamp)
4444
{

test/test_parse_repository.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void test_parse_repository()
5757
repository_t repo = parse_repository(line, strlen(line), 0);
5858

5959
assert_true(str_arr_equals(repo.path, "repo/path"), "Path should be 'repo/path'");
60-
assert_true(str_arr_equals(repo.url, "https://example.com/"), "URL should be 'https://example.com/'");
60+
assert_true(str_arr_equals(repo.url, "https://example.com"), "URL should be 'https://example.com'");
6161

6262
str_free(repo.path);
6363
str_free(repo.name);
@@ -69,7 +69,7 @@ void test_parse_repository()
6969
repository_t repo = parse_repository(line, strlen(line), 0);
7070

7171
assert_true(repo.path.len == 0, "Path should be empty");
72-
assert_true(str_arr_equals(repo.url, "https://example.com/"), "URL should be 'https://example.com/'");
72+
assert_true(str_arr_equals(repo.url, "https://example.com"), "URL should be 'https://example.com'");
7373

7474
str_free(repo.path);
7575
str_free(repo.name);
@@ -93,7 +93,7 @@ void test_parse_repository()
9393
repository_t repo = parse_repository(line, strlen(line), 0);
9494

9595
assert_true(str_arr_equals(repo.path, "repo/path"), "Path should be 'repo/path'");
96-
assert_true(str_arr_equals(repo.url, "https://example.com/repo[name]/"), "URL should be 'https://example.com/repo[name]/'");
96+
assert_true(str_arr_equals(repo.url, "https://example.com/repo[name]"), "URL should be 'https://example.com/repo[name]'");
9797

9898
str_free(repo.path);
9999
str_free(repo.name);
@@ -129,7 +129,7 @@ void test_parse_repository()
129129
repository_t repo = parse_repository(line, strlen(line), 0);
130130

131131
assert_true(str_arr_equals(repo.path, "repo/path"), "Path should be 'repo/path'");
132-
assert_true(str_arr_equals(repo.url, "git@github.com:user/repo.git/"), "URL should be 'git@github.com:user/repo.git/'");
132+
assert_true(str_arr_equals(repo.url, "git@github.com:user/repo.git"), "URL should be 'git@github.com:user/repo.git'");
133133

134134
str_free(repo.path);
135135
str_free(repo.name);

0 commit comments

Comments
 (0)