Merge pull request #65 from cristen/git

Adds python3 support for git and the committer name in the config
This commit is contained in:
Guillaume Ayoub 2013-09-19 07:25:18 -07:00
commit 556afd2ad6
3 changed files with 14 additions and 4 deletions

5
config
View File

@ -89,6 +89,11 @@ http_user_parameter =
http_password_parameter = http_password_parameter =
[git]
# Git default options
committer = Firstname Lastname <Radicale@Radicale.org>
[rights] [rights]
# Rights management method # Rights management method
# Value: None | owner_only | owner_write | from_file # Value: None | owner_only | owner_write | from_file

View File

@ -70,6 +70,9 @@ INITIAL_CONFIG = {
"http_url": "", "http_url": "",
"http_user_parameter": "", "http_user_parameter": "",
"http_password_parameter": ""}, "http_password_parameter": ""},
"git": {
"committer": "Firstname Lastname <Radicale@Radicale.org>",
},
"rights": { "rights": {
"type": "None", "type": "None",
"file": "~/.config/radicale/rights"}, "file": "~/.config/radicale/rights"},

View File

@ -26,16 +26,17 @@ import os
import posixpath import posixpath
import json import json
import time import time
import sys
from contextlib import contextmanager from contextlib import contextmanager
from .. import config, ical from .. import config, ical
FOLDER = os.path.expanduser(config.get("storage", "filesystem_folder")) FOLDER = os.path.expanduser(config.get("storage", "filesystem_folder"))
FILESYSTEM_ENCODING = sys.getfilesystemencoding()
try: try:
from dulwich.repo import Repo from dulwich.repo import Repo
GIT_REPOSITORY = Repo(FOLDER) GIT_REPOSITORY = Repo(FOLDER).encode(FILESYSTEM_ENCODING)
except: except:
GIT_REPOSITORY = None GIT_REPOSITORY = None
@ -52,8 +53,9 @@ def open(path, mode="r"):
# On exit # On exit
if GIT_REPOSITORY and mode == "w": if GIT_REPOSITORY and mode == "w":
path = os.path.relpath(abs_path, FOLDER) path = os.path.relpath(abs_path, FOLDER)
GIT_REPOSITORY.stage([path.encode("utf-8")]) GIT_REPOSITORY.stage([path.encode(FILESYSTEM_ENCODING)])
GIT_REPOSITORY.do_commit("Commit by Radicale") committer = config.get("git", "committer")
GIT_REPOSITORY.do_commit("Commit by Radicale", committer=committer)
# pylint: enable=W0622 # pylint: enable=W0622