Skip to content

fix: allow dots in usernames for non-GitHub git providers#4343

Open
sanmaxdev wants to merge 5 commits into
nf-core:devfrom
sanmaxdev:fix/allow-dots-in-username
Open

fix: allow dots in usernames for non-GitHub git providers#4343
sanmaxdev wants to merge 5 commits into
nf-core:devfrom
sanmaxdev:fix/allow-dots-in-username

Conversation

@sanmaxdev

Copy link
Copy Markdown

Summary

  • Updated the username validation regex in _get_username() to accept dots (.)
  • Made the warning message provider-agnostic (not GitHub-specific)

GitLab and other git providers allow dots in usernames, but the existing regex only accepted alphanumeric characters and hyphens. This blocked module creation for users with dotted usernames on those platforms.

Changes

  • nf_core/components/create.py: Modified regex to include . as a valid character in usernames
  • Updated comment and warning text to refer generically to username validation

Verification

  • ruff format — 1 file already formatted
  • ruff check — All checks passed
  • Regex validation — tested with @user, @user.name, @first.last, @user-name.last
  • Import check — from nf_core.components.create import ComponentCreate passes

Closes #3655

@mashehu

mashehu commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

thanks for the fix.

Can you please add a test in tests/modules/test_create.py for it and also join the github org via the slack channel so the CI runs for you.

@sanmaxdev

Copy link
Copy Markdown
Author

Thanks — added the requested regression coverage in tests/modules/test_create.py.

Verification:

  • VIRTUAL_ENV= uv run --all-extras pytest tests/modules/test_create.py -k dotted_author_username --color=yes — 1 passed, 12 deselected
  • VIRTUAL_ENV= uv run --all-extras ruff check nf_core/components/create.py tests/modules/test_create.py — passed
  • VIRTUAL_ENV= uv run --all-extras ruff format --check nf_core/components/create.py tests/modules/test_create.py — passed

The username validation regex was GitHub-specific and rejected
usernames containing dots, which are valid on GitLab and other
git providers. Updated the regex to accept dots and made the
warning message provider-agnostic.

Fixes nf-core#3655
@sanmaxdev sanmaxdev force-pushed the fix/allow-dots-in-username branch from 0810a02 to b85a7e3 Compare July 2, 2026 05:07
@sanmaxdev

Copy link
Copy Markdown
Author

Added the requested test in tests/modules/test_create.py and kept the PR as a single commit.

Verification:

  • uv run pytest tests/modules/test_create.py::test_modules_create_accepts_dotted_git_provider_username -q
  • uv run ruff check nf_core/components/create.py tests/modules/test_create.py
  • uv run ruff format --check nf_core/components/create.py tests/modules/test_create.py
  • git diff --check

@mashehu mashehu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and please join the github org to have the CI run

Comment thread nf_core/components/create.py Outdated
while self.author is None or not github_username_regex.match(self.author):
if self.author is not None and not github_username_regex.match(self.author):
log.warning("Does not look like a valid GitHub username (must start with an '@')!")
# Regex to validate username (GitHub, GitLab, and other git providers)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Regex to validate username (GitHub, GitLab, and other git providers)
# Regex to validate username (GitHub, GitLab, and other git-based code hosting services)

Comment thread nf_core/components/create.py Outdated
sanmaxdev and others added 2 commits July 2, 2026 16:53
Co-authored-by: Matthias Hörtenhuber <mashehu@users.noreply.github.com>
@sanmaxdev

Copy link
Copy Markdown
Author

Addressed both username validation review points and pushed the update.

Verification:

  • uv run pytest tests/modules/test_create.py::test_modules_create_accepts_dotted_git_provider_username -q
  • uv run ruff check nf_core/components/create.py tests/modules/test_create.py
  • uv run ruff format --check nf_core/components/create.py tests/modules/test_create.py
  • git diff --check

@mashehu

mashehu commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

One more time: join the github org via the slack channel so the CI runs for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants