Introduction
Introduction Statistics Contact Development Disclaimer Help
detect more names for README and LICENSE - stagit-gopher - static git page gene…
git clone git://git.codemadness.org/stagit-gopher
Log
Files
Refs
README
LICENSE
---
commit 4ae2a118c3f7dd0cc7e7b81289152afbada103bc
parent 3a00e5bb2bf0415338ff08d1a7bc9a47b4b751e2
Author: Hiltjo Posthuma <[email protected]>
Date: Sun, 11 Nov 2018 19:07:24 +0100
detect more names for README and LICENSE
- for license: LICENSE, LICENSE.md, COPYING.
- for readme: README, README.md.
Diffstat:
M stagit-gopher.c | 47 ++++++++++++++++++++---------…
1 file changed, 31 insertions(+), 16 deletions(-)
---
diff --git a/stagit-gopher.c b/stagit-gopher.c
@@ -58,12 +58,17 @@ static char *name = "";
static char *strippedname = "";
static char description[255];
static char cloneurl[1024];
-static int haslicense, hasreadme, hassubmodules, hastagsgph;
+static int hastagsgph;
+static char *submodules;
+static char *licensefiles[] = { "HEAD:LICENSE", "HEAD:LICENSE.md", "HEAD:COPYI…
+static char *license;
+static char *readmefiles[] = { "HEAD:README", "HEAD:README.md" };
+static char *readme;
static long long nlogcommits = -1; /* < 0 indicates not used */
/* cache */
static git_oid lastoid;
-static char lastoidstr[GIT_OID_HEXSZ + 2]; /* id + newline + nul byte */
+static char lastoidstr[GIT_OID_HEXSZ + 2]; /* id + newline + NUL byte */
static FILE *rcachefp, *wcachefp;
static const char *cachefile;
@@ -465,12 +470,15 @@ writeheader(FILE *fp, const char *title)
fprintf(fp, "[1|Refs|%s/refs.gph|server|port]\n", relpath);
if (hastagsgph)
fprintf(fp, "[1|Tags|%s/tags.gph|server|port]\n", relpath);
- if (hassubmodules)
- fprintf(fp, "[1|Submodules|%s/file/.gitmodules.gph|server|port…
- if (hasreadme)
- fprintf(fp, "[1|README|%s/file/README.gph|server|port]\n", rel…
- if (haslicense)
- fprintf(fp, "[1|LICENSE|%s/file/LICENSE.gph|server|port]\n", r…
+ if (submodules)
+ fprintf(fp, "[1|Submodules|%s/file/%s.gph|server|port]\n",
+ relpath, submodules);
+ if (readme)
+ fprintf(fp, "[1|README|%s/file/%s.gph|server|port]\n",
+ relpath, readme);
+ if (license)
+ fprintf(fp, "[1|LICENSE|%s/file/%s.gph|server|port]\n",
+ relpath, license);
fputs("---\n", fp);
}
@@ -1218,17 +1226,24 @@ main(int argc, char *argv[])
hastagsgph = (access("tags.gph", F_OK) == 0);
/* check LICENSE */
- haslicense = (!git_revparse_single(&obj, repo, "HEAD:LICENSE") &&
- git_object_type(obj) == GIT_OBJ_BLOB);
- git_object_free(obj);
+ for (i = 0; i < sizeof(licensefiles) / sizeof(*licensefiles) && !licen…
+ if (!git_revparse_single(&obj, repo, licensefiles[i]) &&
+ git_object_type(obj) == GIT_OBJ_BLOB)
+ license = licensefiles[i] + strlen("HEAD:");
+ git_object_free(obj);
+ }
/* check README */
- hasreadme = (!git_revparse_single(&obj, repo, "HEAD:README") &&
- git_object_type(obj) == GIT_OBJ_BLOB);
- git_object_free(obj);
+ for (i = 0; i < sizeof(readmefiles) / sizeof(*readmefiles) && !readme;…
+ if (!git_revparse_single(&obj, repo, readmefiles[i]) &&
+ git_object_type(obj) == GIT_OBJ_BLOB)
+ readme = readmefiles[i] + strlen("HEAD:");
+ git_object_free(obj);
+ }
- hassubmodules = (!git_revparse_single(&obj, repo, "HEAD:.gitmodules") …
- git_object_type(obj) == GIT_OBJ_BLOB);
+ if (!git_revparse_single(&obj, repo, "HEAD:.gitmodules") &&
+ git_object_type(obj) == GIT_OBJ_BLOB)
+ submodules = ".gitmodules";
git_object_free(obj);
/* log for HEAD */
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.