summaryrefslogtreecommitdiffabout
authorLars Hjemli <hjemli@gmail.com>2007-06-18 07:42:10 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2007-06-18 08:38:40 (UTC)
commitf69250358a74efa5d7d9c562b2cdd80fad1430f1 (patch) (unidiff)
tree19c0ddab227d1c27a49046e559618cd067169591
parent4a0be586662843382ecfa53af34a13b291312bc0 (diff)
downloadcgit-f69250358a74efa5d7d9c562b2cdd80fad1430f1.zip
cgit-f69250358a74efa5d7d9c562b2cdd80fad1430f1.tar.gz
cgit-f69250358a74efa5d7d9c562b2cdd80fad1430f1.tar.bz2
Add version info from git-describe
A new script, gen-version.sh, is now invoked from 'make version' to generate the file VERSION. This file contains a version identifier generated by git-describe and is included in the Makefile. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--.gitignore1
-rw-r--r--Makefile29
-rw-r--r--cgit.c3
-rw-r--r--cgit.h2
-rwxr-xr-xgen-version.sh4
-rw-r--r--shared.c2
-rw-r--r--ui-shared.c2
7 files changed, 27 insertions, 16 deletions
diff --git a/.gitignore b/.gitignore
index c4c9ac3..5664962 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
1# Files I don't care to see in git-status/commit 1# Files I don't care to see in git-status/commit
2cgit 2cgit
3VERSION
3*.o 4*.o
4*~ 5*~
diff --git a/Makefile b/Makefile
index c2a5736..e69ad7e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,22 +1,30 @@
1CGIT_VERSION = 0.5
2
3prefix = /var/www/htdocs/cgit 1prefix = /var/www/htdocs/cgit
4
5SHA1_HEADER = <openssl/sha.h> 2SHA1_HEADER = <openssl/sha.h>
6CACHE_ROOT = /var/cache/cgit 3CACHE_ROOT = /var/cache/cgit
7CGIT_CONFIG = /etc/cgitrc 4CGIT_CONFIG = /etc/cgitrc
8CGIT_SCRIPT_NAME = cgit.cgi 5CGIT_SCRIPT_NAME = cgit.cgi
9 6
10# 7#
11# Let the user override the above settings. 8# Let the user override the above settings.
12# 9#
13-include cgit.conf 10-include cgit.conf
14 11
12
13CGIT_VERSION = 0.5
14
15all: cgit
16
17VERSION:
18 gen-version.sh
19
20-include VERSION
21
22
15EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lcrypto 23EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lcrypto
16OBJECTS = shared.o cache.o parsing.o html.o ui-shared.o ui-repolist.o \ 24OBJECTS = shared.o cache.o parsing.o html.o ui-shared.o ui-repolist.o \
17 ui-summary.o ui-log.o ui-tree.o ui-commit.o ui-diff.o \ 25 ui-summary.o ui-log.o ui-tree.o ui-commit.o ui-diff.o \
18 ui-snapshot.o ui-blob.o 26 ui-snapshot.o ui-blob.o
19 27
20CFLAGS += -Wall 28CFLAGS += -Wall
21 29
22ifdef DEBUG 30ifdef DEBUG
@@ -37,22 +45,17 @@ GITVER = $(shell git version 2>/dev/null || echo nogit)
37ifeq ($(GITVER),nogit) 45ifeq ($(GITVER),nogit)
38GITURL = http://www.kernel.org/pub/software/scm/git/git-1.5.2.tar.bz2 46GITURL = http://www.kernel.org/pub/software/scm/git/git-1.5.2.tar.bz2
39INITGIT = test -e git/git.c || ((curl "$(GITURL)" | tar -xj) && mv git-1.5.2 git) 47INITGIT = test -e git/git.c || ((curl "$(GITURL)" | tar -xj) && mv git-1.5.2 git)
40else 48else
41INITGIT = ./submodules.sh -i 49INITGIT = ./submodules.sh -i
42endif 50endif
43 51
44 52
45# 53cgit: cgit.c cgit.h VERSION $(OBJECTS)
46# basic build rules
47#
48all: cgit
49
50cgit: cgit.c cgit.h $(OBJECTS)
51 $(CC) $(CFLAGS) cgit.c -o cgit $(OBJECTS) $(EXTLIBS) 54 $(CC) $(CFLAGS) cgit.c -o cgit $(OBJECTS) $(EXTLIBS)
52 55
53$(OBJECTS): cgit.h git/libgit.a 56$(OBJECTS): cgit.h git/libgit.a
54 57
55git/libgit.a: 58git/libgit.a:
56 $(INITGIT) 59 $(INITGIT)
57 $(MAKE) -C git 60 $(MAKE) -C git
58 61
@@ -60,17 +63,17 @@ git/libgit.a:
60# phony targets 63# phony targets
61# 64#
62install: all clean-cache 65install: all clean-cache
63 mkdir -p $(prefix) 66 mkdir -p $(prefix)
64 install cgit $(prefix)/$(CGIT_SCRIPT_NAME) 67 install cgit $(prefix)/$(CGIT_SCRIPT_NAME)
65 install cgit.css $(prefix)/cgit.css 68 install cgit.css $(prefix)/cgit.css
66 69
67clean-cgit: 70clean-cgit:
68 rm -f cgit *.o 71 rm -f cgit VERSION *.o
69 72
70distclean-cgit: clean-cgit 73distclean-cgit: clean-cgit
71 git clean -d -x 74 git clean -d -x
72 75
73clean-sub: 76clean-sub:
74 $(MAKE) -C git clean 77 $(MAKE) -C git clean
75 78
76distclean-sub: clean-sub 79distclean-sub: clean-sub
@@ -78,10 +81,14 @@ distclean-sub: clean-sub
78 81
79clean-cache: 82clean-cache:
80 rm -rf $(CACHE_ROOT)/* 83 rm -rf $(CACHE_ROOT)/*
81 84
82clean: clean-cgit clean-sub 85clean: clean-cgit clean-sub
83 86
84distclean: distclean-cgit distclean-sub 87distclean: distclean-cgit distclean-sub
85 88
89version: clean-cgit
90 ./gen-version.sh
91 make
92
86.PHONY: all install clean clean-cgit clean-sub clean-cache \ 93.PHONY: all install clean clean-cgit clean-sub clean-cache \
87 distclean distclean-cgit distclean-sub 94 distclean distclean-cgit distclean-sub release version
diff --git a/cgit.c b/cgit.c
index 3fc90bf..11dff76 100644
--- a/cgit.c
+++ b/cgit.c
@@ -3,19 +3,16 @@
3 * Copyright (C) 2006 Lars Hjemli 3 * Copyright (C) 2006 Lars Hjemli
4 * 4 *
5 * Licensed under GNU General Public License v2 5 * Licensed under GNU General Public License v2
6 * (see COPYING for full license text) 6 * (see COPYING for full license text)
7 */ 7 */
8 8
9#include "cgit.h" 9#include "cgit.h"
10 10
11const char cgit_version[] = CGIT_VERSION;
12
13
14static int cgit_prepare_cache(struct cacheitem *item) 11static int cgit_prepare_cache(struct cacheitem *item)
15{ 12{
16 if (!cgit_repo && cgit_query_repo) { 13 if (!cgit_repo && cgit_query_repo) {
17 char *title = fmt("%s - %s", cgit_root_title, "Bad request"); 14 char *title = fmt("%s - %s", cgit_root_title, "Bad request");
18 cgit_print_docstart(title, item); 15 cgit_print_docstart(title, item);
19 cgit_print_pageheader(title, 0); 16 cgit_print_pageheader(title, 0);
20 cgit_print_error(fmt("Unknown repo: %s", cgit_query_repo)); 17 cgit_print_error(fmt("Unknown repo: %s", cgit_query_repo));
21 cgit_print_docend(); 18 cgit_print_docend();
diff --git a/cgit.h b/cgit.h
index bd2dd0d..9558362 100644
--- a/cgit.h
+++ b/cgit.h
@@ -93,17 +93,17 @@ struct commitinfo {
93 93
94struct taginfo { 94struct taginfo {
95 char *tagger; 95 char *tagger;
96 char *tagger_email; 96 char *tagger_email;
97 int tagger_date; 97 int tagger_date;
98 char *msg; 98 char *msg;
99}; 99};
100 100
101extern const char cgit_version[]; 101extern const char *cgit_version;
102 102
103extern struct repolist cgit_repolist; 103extern struct repolist cgit_repolist;
104extern struct repoinfo *cgit_repo; 104extern struct repoinfo *cgit_repo;
105extern int cgit_cmd; 105extern int cgit_cmd;
106 106
107extern char *cgit_root_title; 107extern char *cgit_root_title;
108extern char *cgit_css; 108extern char *cgit_css;
109extern char *cgit_logo; 109extern char *cgit_logo;
diff --git a/gen-version.sh b/gen-version.sh
new file mode 100755
index 0000000..4c60f60
--- a/dev/null
+++ b/gen-version.sh
@@ -0,0 +1,4 @@
1v=$(git-describe --abbrev=4 HEAD | sed -e 's/-/./g')
2test -z "$v" && exit 1
3echo "CGIT_VERSION = $v"
4echo "CGIT_VERSION = $v" > VERSION
diff --git a/shared.c b/shared.c
index f20fb5c..f7f43b2 100644
--- a/shared.c
+++ b/shared.c
@@ -7,16 +7,18 @@
7 */ 7 */
8 8
9#include "cgit.h" 9#include "cgit.h"
10 10
11struct repolist cgit_repolist; 11struct repolist cgit_repolist;
12struct repoinfo *cgit_repo; 12struct repoinfo *cgit_repo;
13int cgit_cmd; 13int cgit_cmd;
14 14
15const char *cgit_version = CGIT_VERSION;
16
15char *cgit_root_title = "Git repository browser"; 17char *cgit_root_title = "Git repository browser";
16char *cgit_css = "/cgit.css"; 18char *cgit_css = "/cgit.css";
17char *cgit_logo = "/git-logo.png"; 19char *cgit_logo = "/git-logo.png";
18char *cgit_index_header = NULL; 20char *cgit_index_header = NULL;
19char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/"; 21char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/";
20char *cgit_module_link = "./?repo=%s&page=commit&id=%s"; 22char *cgit_module_link = "./?repo=%s&page=commit&id=%s";
21char *cgit_agefile = "info/web/last-modified"; 23char *cgit_agefile = "info/web/last-modified";
22char *cgit_virtual_root = NULL; 24char *cgit_virtual_root = NULL;
diff --git a/ui-shared.c b/ui-shared.c
index 15d8254..110c696 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -257,17 +257,17 @@ void cgit_print_docstart(char *title, struct cacheitem *item)
257 ttl_seconds(item->ttl))); 257 ttl_seconds(item->ttl)));
258 html("\n"); 258 html("\n");
259 html(cgit_doctype); 259 html(cgit_doctype);
260 html("<html>\n"); 260 html("<html>\n");
261 html("<head>\n"); 261 html("<head>\n");
262 html("<title>"); 262 html("<title>");
263 html_txt(title); 263 html_txt(title);
264 html("</title>\n"); 264 html("</title>\n");
265 htmlf("<meta name='generator' content='cgit v%s'/>\n", cgit_version); 265 htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version);
266 html("<link rel='stylesheet' type='text/css' href='"); 266 html("<link rel='stylesheet' type='text/css' href='");
267 html_attr(cgit_css); 267 html_attr(cgit_css);
268 html("'/>\n"); 268 html("'/>\n");
269 html("</head>\n"); 269 html("</head>\n");
270 html("<body>\n"); 270 html("<body>\n");
271} 271}
272 272
273void cgit_print_docend() 273void cgit_print_docend()