Skip to content

Unable to init a daap with valid local git config #105

Description

@leslem

dp_init doesn't work for me with my otherwise valid git config.

My global git config automatically chooses which email to use based on the remote url.

# ~/.gitconfig
[includeIf "hasconfig:remote.*.url:https://github.com/leslem/*"]
	path = ~/.gitconfig_personal
[includeIf "hasconfig:remote.*.url:https://github.com/emeryl1_BMS/*"]
	path = ~/.gitconfig_company

# ~/.gitconfig_personal
[user]
    email = example@mydomain.com

# ~/.gitconfig_company
[user]
    email = example@company.com

However, this breaks dp_init. I get an error from this section of code:

git user.email not configured. Set git user.email by git2r::config(global = T, "user.email = \"<YOUR_EMAIL>\")

As written, the checks for user.email and user.name will fail if someone uses a local .gitconfig file as well, so these two error checks should be updated to account for global and local config settings.
I tried removing the stop() command and instead got an error from git2r::get_default_signature(), traced back to this git2r::commit() command.

Error in default_signature(repo) : 
  Error in 'git2r_signature_default': config value 'user.email' was not found
  4. default_signature(repo)
  3. git2r::commit(repo, message = "project init")
  2. dp_git_init(project_path = project_path, project_name = project_name,
  branch_name = branch_name, github_repo_url = github_repo_url,
  board_params_set_dried = board_params_set_dried, creds_set_dried = creds_set_dried,
  git_ignore = git_ignore)
  1. dp_init(project_path = "~/devel/dp-test-daapr-combined", project_description = "Testing whether the combined daapr wroks",
  branch_name = "main", branch_description = "Main", readme_general_note = "",
  board_params_set_dried = board_params_set_dried, github_repo_url = "https://github.com/<company>/dp-test-daapr-combined.git")

git2r can't seem to resolve the config fully, but command line git can:

R > git2r::config()$global$user.email
NULL
R > git2r::config()$local$user.email
NULL

zsh $ git config user.email
example@company.com

At that point I ran out of steam for tracking this issue and will temporarily set the user email in my global config for the sake of setting up the daap I'm working on.

Notably, this hasn't been an issue for me in running dpcommit on an existing daap.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    Status
    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions