From 1778cba9794bbe5624db907bda2d065c971405b7 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Sat, 26 Dec 2015 12:55:59 +0100 Subject: [PATCH] allow to specify clone url, displayed in header --- urmoms.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/urmoms.c b/urmoms.c index de79787..f484f66 100644 --- a/urmoms.c +++ b/urmoms.c @@ -44,6 +44,7 @@ static const char *repodir; static char name[255]; static char description[255]; +static char cloneurl[1024]; static int hasreadme, haslicense; void @@ -232,7 +233,15 @@ writeheader(FILE *fp) xmlencode(fp, name, strlen(name)); fputs("", fp); xmlencode(fp, description, strlen(description)); - fputs("\n", fp); + fputs("", fp); + if (cloneurl[0]) { + fputs("git clone ", fp); + xmlencode(fp, cloneurl, strlen(cloneurl)); + fputs("", fp); + } + fputs("\n", fp); fprintf(fp, "Log | ", relpath); fprintf(fp, "Files", relpath); if (hasreadme) @@ -730,6 +739,20 @@ main(int argc, char *argv[]) fclose(fpread); } + /* read url or .git/url */ + snprintf(path, sizeof(path), "%s%s%s", + repodir, repodir[strlen(repodir)] == '/' ? "" : "/", "url"); + if (!(fpread = fopen(path, "r"))) { + snprintf(path, sizeof(path), "%s%s%s", + repodir, repodir[strlen(repodir)] == '/' ? "" : "/", ".git/url"); + fpread = fopen(path, "r"); + } + if (fpread) { + if (!fgets(cloneurl, sizeof(cloneurl), fpread)) + cloneurl[0] = '\0'; + fclose(fpread); + } + /* check LICENSE */ haslicense = !git_revparse_single(&obj, repo, "HEAD:LICENSE"); git_object_free(obj); -- libgit2 1.1.1