Skip to content

Commit

Permalink
feat: Use user's name in project GitHub URL instead of "unknown" (#1275)
Browse files Browse the repository at this point in the history
  • Loading branch information
xuanzhi33 authored Mar 7, 2024
1 parent dd727c5 commit 371d850
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 42 deletions.
6 changes: 3 additions & 3 deletions src/hatch/template/files_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ def __init__(self, template_config: dict, plugin_config: dict):
plugin_config['project_urls']
if 'project_urls' in plugin_config
else {
'Documentation': 'https://github.com/unknown/{project_name_normalized}#readme',
'Issues': 'https://github.com/unknown/{project_name_normalized}/issues',
'Source': 'https://github.com/unknown/{project_name_normalized}',
'Documentation': 'https://github.com/{name}/{project_name_normalized}#readme',
'Issues': 'https://github.com/{name}/{project_name_normalized}/issues',
'Source': 'https://github.com/{name}/{project_name_normalized}',
}
)
if project_urls:
Expand Down
6 changes: 3 additions & 3 deletions tests/cli/new/test_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@ def test_licenses_empty(hatch, helpers, config_file, temp_dir):
def test_projects_urls_space_in_label(hatch, helpers, config_file, temp_dir):
project_name = 'My.App'
config_file.model.template.plugins['default']['project_urls'] = {
'Documentation': 'https://github.com/unknown/{project_name_normalized}#readme',
'Source': 'https://github.com/unknown/{project_name_normalized}',
'Bug Tracker': 'https://github.com/unknown/{project_name_normalized}/issues',
'Documentation': 'https://github.com/{name}/{project_name_normalized}#readme',
'Source': 'https://github.com/{name}/{project_name_normalized}',
'Bug Tracker': 'https://github.com/{name}/{project_name_normalized}/issues',
}
config_file.save()

Expand Down
30 changes: 15 additions & 15 deletions tests/cli/project/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ def test_default_all(self, hatch, temp_dir, helpers):
"Programming Language :: Python :: Implementation :: PyPy"
],
"urls": {{
"Documentation": "https://github.com/unknown/my-app#readme",
"Issues": "https://github.com/unknown/my-app/issues",
"Source": "https://github.com/unknown/my-app"
"Documentation": "https://github.com/Foo Bar/my-app#readme",
"Issues": "https://github.com/Foo Bar/my-app/issues",
"Source": "https://github.com/Foo Bar/my-app"
}}
}}
"""
Expand Down Expand Up @@ -132,9 +132,9 @@ def test_field_complex(self, hatch, temp_dir, helpers):
assert result.output == helpers.dedent(
"""
{
"Documentation": "https://github.com/unknown/my-app#readme",
"Issues": "https://github.com/unknown/my-app/issues",
"Source": "https://github.com/unknown/my-app"
"Documentation": "https://github.com/Foo Bar/my-app#readme",
"Issues": "https://github.com/Foo Bar/my-app/issues",
"Source": "https://github.com/Foo Bar/my-app"
}
"""
)
Expand Down Expand Up @@ -220,9 +220,9 @@ def test_default_all(self, hatch, temp_dir, helpers):
"Programming Language :: Python :: Implementation :: PyPy"
],
"urls": {{
"Documentation": "https://github.com/unknown/my-app#readme",
"Issues": "https://github.com/unknown/my-app/issues",
"Source": "https://github.com/unknown/my-app"
"Documentation": "https://github.com/Foo Bar/my-app#readme",
"Issues": "https://github.com/Foo Bar/my-app/issues",
"Source": "https://github.com/Foo Bar/my-app"
}}
}}
"""
Expand Down Expand Up @@ -303,9 +303,9 @@ def test_field_complex(self, hatch, temp_dir, helpers):
"""
Setting up build environment for missing dependencies
{
"Documentation": "https://github.com/unknown/my-app#readme",
"Issues": "https://github.com/unknown/my-app/issues",
"Source": "https://github.com/unknown/my-app"
"Documentation": "https://github.com/Foo Bar/my-app#readme",
"Issues": "https://github.com/Foo Bar/my-app/issues",
"Source": "https://github.com/Foo Bar/my-app"
}
"""
)
Expand Down Expand Up @@ -372,9 +372,9 @@ def test_plugin_dependencies_unmet(self, hatch, temp_dir, helpers, mock_plugin_i
"Programming Language :: Python :: Implementation :: PyPy"
],
"urls": {{
"Documentation": "https://github.com/unknown/my-app#readme",
"Issues": "https://github.com/unknown/my-app/issues",
"Source": "https://github.com/unknown/my-app"
"Documentation": "https://github.com/Foo Bar/my-app#readme",
"Issues": "https://github.com/Foo Bar/my-app/issues",
"Source": "https://github.com/Foo Bar/my-app"
}}
}}
"""
Expand Down
6 changes: 3 additions & 3 deletions tests/helpers/templates/new/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ def get_files(**kwargs):
dependencies = []
[project.urls]
Documentation = "https://github.com/unknown/{kwargs['project_name_normalized']}#readme"
Issues = "https://github.com/unknown/{kwargs['project_name_normalized']}/issues"
Source = "https://github.com/unknown/{kwargs['project_name_normalized']}"
Documentation = "https://github.com/{kwargs['author']}/{kwargs['project_name_normalized']}#readme"
Issues = "https://github.com/{kwargs['author']}/{kwargs['project_name_normalized']}/issues"
Source = "https://github.com/{kwargs['author']}/{kwargs['project_name_normalized']}"
[tool.hatch.version]
path = "src/{kwargs['package_name']}/__about__.py"
Expand Down
6 changes: 3 additions & 3 deletions tests/helpers/templates/new/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ def get_files(**kwargs):
dependencies = []
[project.urls]
Documentation = "https://github.com/unknown/{kwargs['project_name_normalized']}#readme"
Issues = "https://github.com/unknown/{kwargs['project_name_normalized']}/issues"
Source = "https://github.com/unknown/{kwargs['project_name_normalized']}"
Documentation = "https://github.com/{kwargs['author']}/{kwargs['project_name_normalized']}#readme"
Issues = "https://github.com/{kwargs['author']}/{kwargs['project_name_normalized']}/issues"
Source = "https://github.com/{kwargs['author']}/{kwargs['project_name_normalized']}"
[tool.hatch.version]
path = "src/{kwargs['package_name']}/__about__.py"
Expand Down
6 changes: 3 additions & 3 deletions tests/helpers/templates/new/feature_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ def {kwargs['package_name']}():
]
[project.urls]
Documentation = "https://github.com/unknown/{kwargs['project_name_normalized']}#readme"
Issues = "https://github.com/unknown/{kwargs['project_name_normalized']}/issues"
Source = "https://github.com/unknown/{kwargs['project_name_normalized']}"
Documentation = "https://github.com/{kwargs['author']}/{kwargs['project_name_normalized']}#readme"
Issues = "https://github.com/{kwargs['author']}/{kwargs['project_name_normalized']}/issues"
Source = "https://github.com/{kwargs['author']}/{kwargs['project_name_normalized']}"
[project.scripts]
{kwargs['project_name_normalized']} = "{kwargs['package_name']}.cli:{kwargs['package_name']}"
Expand Down
6 changes: 3 additions & 3 deletions tests/helpers/templates/new/feature_no_src_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ def get_files(**kwargs):
dependencies = []
[project.urls]
Documentation = "https://github.com/unknown/{kwargs['project_name_normalized']}#readme"
Issues = "https://github.com/unknown/{kwargs['project_name_normalized']}/issues"
Source = "https://github.com/unknown/{kwargs['project_name_normalized']}"
Documentation = "https://github.com/{kwargs['author']}/{kwargs['project_name_normalized']}#readme"
Issues = "https://github.com/{kwargs['author']}/{kwargs['project_name_normalized']}/issues"
Source = "https://github.com/{kwargs['author']}/{kwargs['project_name_normalized']}"
[tool.hatch.version]
path = "{kwargs['package_name']}/__about__.py"
Expand Down
6 changes: 3 additions & 3 deletions tests/helpers/templates/new/licenses_empty.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ def get_files(**kwargs):
dependencies = []
[project.urls]
Documentation = "https://github.com/unknown/{kwargs['project_name_normalized']}#readme"
Issues = "https://github.com/unknown/{kwargs['project_name_normalized']}/issues"
Source = "https://github.com/unknown/{kwargs['project_name_normalized']}"
Documentation = "https://github.com/{kwargs['author']}/{kwargs['project_name_normalized']}#readme"
Issues = "https://github.com/{kwargs['author']}/{kwargs['project_name_normalized']}/issues"
Source = "https://github.com/{kwargs['author']}/{kwargs['project_name_normalized']}"
[tool.hatch.version]
path = "src/{kwargs['package_name']}/__about__.py"
Expand Down
6 changes: 3 additions & 3 deletions tests/helpers/templates/new/licenses_multiple.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ def get_files(**kwargs):
dependencies = []
[project.urls]
Documentation = "https://github.com/unknown/{kwargs['project_name_normalized']}#readme"
Issues = "https://github.com/unknown/{kwargs['project_name_normalized']}/issues"
Source = "https://github.com/unknown/{kwargs['project_name_normalized']}"
Documentation = "https://github.com/{kwargs['author']}/{kwargs['project_name_normalized']}#readme"
Issues = "https://github.com/{kwargs['author']}/{kwargs['project_name_normalized']}/issues"
Source = "https://github.com/{kwargs['author']}/{kwargs['project_name_normalized']}"
[tool.hatch.version]
path = "src/{kwargs['package_name']}/__about__.py"
Expand Down
6 changes: 3 additions & 3 deletions tests/helpers/templates/new/projects_urls_space_in_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ def get_files(**kwargs):
dependencies = []
[project.urls]
Documentation = "https://github.com/unknown/{kwargs['project_name_normalized']}#readme"
Source = "https://github.com/unknown/{kwargs['project_name_normalized']}"
"Bug Tracker" = "https://github.com/unknown/{kwargs['project_name_normalized']}/issues"
Documentation = "https://github.com/{kwargs['author']}/{kwargs['project_name_normalized']}#readme"
Source = "https://github.com/{kwargs['author']}/{kwargs['project_name_normalized']}"
"Bug Tracker" = "https://github.com/{kwargs['author']}/{kwargs['project_name_normalized']}/issues"
[tool.hatch.version]
path = "src/{kwargs['package_name']}/__about__.py"
Expand Down

0 comments on commit 371d850

Please sign in to comment.