Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions renku/cli/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"""

import ast
import configparser
import os
from collections import OrderedDict, namedtuple
from pathlib import Path
Expand All @@ -73,6 +74,7 @@
import attr
import click
import pkg_resources
from git import Repo

from renku.core import errors
from renku.core.commands.client import pass_local_client
Expand Down Expand Up @@ -165,6 +167,19 @@ def is_path_empty(path):
return not any(gen)


def check_git_user_config():
"""Check that git user information is configured."""
dummy_git_folder = mkdtemp()
repo = Repo.init(dummy_git_folder)
git_config = repo.config_reader()
try:
git_config.get_value('user', 'name', None)
git_config.get_value('user', 'email', None)
return True
except (configparser.NoOptionError, configparser.NoSectionError):
return False


@click.command()
@click.argument(
'path',
Expand Down Expand Up @@ -214,6 +229,15 @@ def init(
'flag to transform it into a Renku repository.'.format(str(path))
)

if not check_git_user_config():
raise errors.ConfigurationError(
'The user name and email are not configured. '
'Please use the "git config" command to configure them.\n\n'
'\tgit config --global --add user.name "John Doe"\n'
'\tgit config --global --add user.email '
'"john.doe@example.com"\n'
)

# select template source
if template_source:
click.echo(
Expand Down