From 0392d2b3de8342ad6aca0c695db7966196144eb8 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Nov 03 2014 10:12:55 +0000 Subject: Add a method to retrieve the username in case the project is a fork --- diff --git a/progit/hooks/files/progit_hook.py b/progit/hooks/files/progit_hook.py index e02e9aa..1402cf0 100644 --- a/progit/hooks/files/progit_hook.py +++ b/progit/hooks/files/progit_hook.py @@ -105,6 +105,8 @@ def generate_revision_change_log(new_commits_list): def relates_commit(commitid, issueid, project=None): ''' Add a comment to an issue that this commit relates to it. ''' repo = project or get_repo_name() + username = get_username() + print 'username:', username issue = progit.lib.get_issue(progit.SESSION, repo.id, issueid) @@ -179,6 +181,16 @@ def get_repo_name(): return repo +def get_username(): + ''' Return the username of the git repo based on its path. + ''' + username = None + repo = os.path.abspath(os.path.join(os.getcwd(), '..')) + if progit.APP.config['FORK_FOLDER'] in repo: + username = repo.split(progit.APP.config['FORK_FOLDER'])[1] + return username + + def get_pusher(commit): ''' Return the name of the person that pushed the commit. ''' user = None