git » wikiri » commit 12ee224

Use the remote IP address for commit authorship.

author Alberto Bertogli
2007-12-31 14:47:07 UTC
committer Alberto Bertogli
2007-12-31 14:47:07 UTC
parent 592eccd408a5b0d8ad0a955dcb1370b61dcc24cc

Use the remote IP address for commit authorship.

Signed-off-by: Alberto Bertogli <albertito@gmail.com>

wikiri.cgi +6 -3

diff --git a/wikiri.cgi b/wikiri.cgi
index ca7f2fb..b90abba 100755
--- a/wikiri.cgi
+++ b/wikiri.cgi
@@ -888,6 +888,9 @@ def handle_cgi():
 	if not comment:
 		comment = "No comment"
 
+	remoteip = os.environ.get("REMOTE_ADDR", "unknownip")
+	author = "Somebody <%s@wikiri>" % remoteip
+
 	if os.environ.has_key('PATH_INFO'):
 		path_info = os.environ['PATH_INFO']
 		path_info = os.path.normpath(path_info)
@@ -921,12 +924,12 @@ def handle_cgi():
 		if newcontent.strip():
 			a.save(newtitle, newcontent)
 			h.add(a.qname)
-			h.commit(msg = comment)
+			h.commit(msg = comment, author = author)
 			render_article(a)
 		else:
 			a.remove()
 			h.remove(a.qname)
-			h.commit(msg = comment)
+			h.commit(msg = comment, author = author)
 			render_removed(a.name)
 	elif log:
 		a = Article(artname)
@@ -947,7 +950,7 @@ def handle_cgi():
 		a.save(None, oldcontent, raw = True)
 		h.add(a.qname)
 		ctime = h.get_commit(cid)['atime'].strftime("%Y-%m-%d %H:%M:%S")
-		h.commit(msg = 'Restored ' + ctime)
+		h.commit(msg = 'Restored ' + ctime, author = author)
 
 		render_article(a)
 	else: