summaryrefslogtreecommitdiff
path: root/src/github
diff options
context:
space:
mode:
authorGravatar Anshul Gupta <ansg191@anshulg.com> 2025-06-13 15:55:55 -0700
committerGravatar Anshul Gupta <ansg191@anshulg.com> 2025-06-13 15:59:55 -0700
commit6bf51383587f7d6ff31f253dba5fa6d2209fee6d (patch)
treec33fe7e87b312e3618aaebe72da6c8bd6a6e6be4 /src/github
parentd814e2111a539bacf8be4958a6cea14040490015 (diff)
downloadgithub-mirror-6bf51383587f7d6ff31f253dba5fa6d2209fee6d.tar.gz
github-mirror-6bf51383587f7d6ff31f253dba5fa6d2209fee6d.tar.zst
github-mirror-6bf51383587f7d6ff31f253dba5fa6d2209fee6d.zip
Add ssh transport option for github
Diffstat (limited to 'src/github')
-rw-r--r--src/github/types.c24
-rw-r--r--src/github/types.h1
2 files changed, 25 insertions, 0 deletions
diff --git a/src/github/types.c b/src/github/types.c
index ce9441e..a80e8fc 100644
--- a/src/github/types.c
+++ b/src/github/types.c
@@ -119,6 +119,29 @@ int gh_list_repos_from_json(cJSON *root, struct gh_list_repos_res *res)
status = -1;
goto end;
}
+ cJSON *ssh_url_v = cJSON_GetObjectItemCaseSensitive(repo,
+ "sshUrl");
+ if (!ssh_url_v || !cJSON_IsString(ssh_url_v)) {
+ fprintf(stderr, "Error: sshUrl not found\n");
+ status = -1;
+ goto end;
+ }
+ const char *prefix = "ssh://";
+ char *ssh_url = malloc(strlen(prefix) +
+ strlen(ssh_url_v->valuestring) + 1);
+ if (!ssh_url) {
+ fprintf(stderr, "Error: malloc failed\n");
+ status = -1;
+ goto end;
+ }
+ strcpy(ssh_url, prefix);
+ strcat(ssh_url, ssh_url_v->valuestring);
+ // Replace 2nd colon with slash
+ char *colon = strchr(ssh_url + strlen(prefix), ':');
+ if (colon)
+ *colon = '/';
+
+
cJSON *is_fork = cJSON_GetObjectItemCaseSensitive(repo,
"isFork");
if (!is_fork || !cJSON_IsBool(is_fork)) {
@@ -136,6 +159,7 @@ int gh_list_repos_from_json(cJSON *root, struct gh_list_repos_res *res)
res->repos[res->repos_len].name = strdup(name->valuestring);
res->repos[res->repos_len].url = strdup(url->valuestring);
+ res->repos[res->repos_len].ssh_url = ssh_url;
res->repos[res->repos_len].is_fork = cJSON_IsTrue(is_fork);
res->repos[res->repos_len].is_private =
cJSON_IsTrue(is_private);
diff --git a/src/github/types.h b/src/github/types.h
index dec3551..fa88e27 100644
--- a/src/github/types.h
+++ b/src/github/types.h
@@ -16,6 +16,7 @@ struct gh_list_repos_res {
struct {
char *name;
char *url;
+ char *ssh_url;
int is_fork;
int is_private;
} *repos;