Repository: beeware/briefcase

Issue:
Briefcase's attempt to set the URL for the `origin` remote for templates can fail with certain Git config
### Describe the bug

The configuration below can cause Briefcase to fail to roll out templates.
```ini
[url "ssh://git@github.com/"]
    insteadOf = https://github.com/
```
```console
❯ briefcase new --no-input -vvv

[helloworld] Generating a new application 'Hello World'
Using app template: https://github.com/beeware/briefcase-template, branch v0.3.20
DEBUG git.util: Failed checking if running in CYGWIN due to: FileNotFoundError(2, 'No such file or directory')
DEBUG git.cmd: Popen(['git', 'remote', 'set-url', '--', 'origin', 'https://github.com/beeware/briefcase-template', 'https://github.com/beeware/briefcase-template'], cwd=/Users/rmartin/Library/Caches/org.beeware.briefcase/templates/briefcase-template, stdin=None, shell=False, universal_newlines=False)

Unable to check out template branch.

This may be because your computer is offline, or because the template repository
is in a weird state. If you have a stable network connection, try deleting:

    /Users/rmartin/Library/Caches/org.beeware.briefcase/templates/briefcase-template

and retrying your command.

Log saved to /Users/rmartin/tmp/beeware/logs/briefcase.2024_12_08-11_33_10.new.log
```
This is the actual error from Git:
```console
GitCommandError: Cmd('git') failed due to: exit code(128)
  cmdline: git remote set-url -- origin https://github.com/beeware/briefcase-template https://github.com/beeware/briefcase-template
  stderr: 'fatal: No such URL found: https://github.com/beeware/briefcase-template'
```

### Steps to reproduce

1. Add the configuration above to `~/.gitconfig`
2. Run `briefcase new --no-input`


### Expected behavior

Briefcase should not fail to use templates because it cannot update the URL of the `origin` remote....especially since this was added largely for the benefit of Briefcase developers...

Instead:
1) Briefcase should log a warning and move on using the template
2) Briefcase could try to update the URL without specifying an "old url"

As for number 2, specifying the "old url" is optional. Given that Briefcase is supposed to be managing these cloned repos, it seems like it should be fine to just blindly update the URL for the `origin` remote.

### Screenshots

_No response_

### Environment

- Operating System: Sequoia
- Python version: 3.12.7
- Software versions:
  - Briefcase: `0.3.20`

### Logs

[briefcase.2024_12_08-11_33_10.new.log](https://github.com/user-attachments/files/18053171/briefcase.2024_12_08-11_33_10.new.log)


### Additional context

_No response_

Discussion:

Patch:
diff --git a/changes/2077.bugfix.rst b/changes/2077.bugfix.rst
new file mode 100644
index 00000000..2991a96d
--- /dev/null
+++ b/changes/2077.bugfix.rst
@@ -0,0 +1,1 @@
+Briefcase no longer fails to create projects or builds because it cannot update the Git configuration for the relevant template.
diff --git a/src/briefcase/commands/base.py b/src/briefcase/commands/base.py
index 418826f2..75fb393b 100644
--- a/src/briefcase/commands/base.py
+++ b/src/briefcase/commands/base.py
@@ -1014,7 +1014,7 @@ Did you run Briefcase in a project directory that contains {filename.name!r}?"""
                 # Ensure the existing repo's origin URL points to the location
                 # being requested. A difference can occur, for instance, if a
                 # fork of the template is used.
-                remote.set_url(new_url=template, old_url=remote.url)
+                remote.set_url(new_url=template)
                 try:
                     # Attempt to update the repository
                     remote.fetch()


Test patch:
diff --git a/tests/commands/base/test_update_cookiecutter_cache.py b/tests/commands/base/test_update_cookiecutter_cache.py
index 052f0f50..82673e85 100644
--- a/tests/commands/base/test_update_cookiecutter_cache.py
+++ b/tests/commands/base/test_update_cookiecutter_cache.py
@@ -219,7 +219,6 @@ def test_existing_repo_template(base_command, mock_git):
     mock_repo.remote.assert_called_once_with(name="origin")
     mock_remote.set_url.assert_called_once_with(
         new_url="https://example.com/magic/special-template.git",
-        old_url="https://example.com/magic/special-template.git",
     )
     mock_remote.fetch.assert_called_once_with()
 
@@ -307,7 +306,6 @@ def test_existing_repo_template_with_different_url(base_command, mock_git):
     mock_repo.remote.assert_called_once_with(name="origin")
     mock_remote.set_url.assert_called_once_with(
         new_url="https://example.com/magic/special-template.git",
-        old_url="https://example.com/existing/special-template.git",
     )
     mock_remote.fetch.assert_called_once_with()
 
@@ -356,7 +354,6 @@ def test_offline_repo_template(base_command, mock_git, capsys):
     mock_repo.remote.assert_called_once_with(name="origin")
     mock_remote.set_url.assert_called_once_with(
         new_url="https://example.com/magic/special-template.git",
-        old_url="https://example.com/magic/special-template.git",
     )
     mock_remote.fetch.assert_called_once_with()
 
@@ -407,7 +404,6 @@ def test_cached_missing_branch_template(base_command, mock_git):
     mock_repo.remote.assert_called_once_with(name="origin")
     mock_remote.set_url.assert_called_once_with(
         new_url="https://example.com/magic/special-template.git",
-        old_url="https://example.com/magic/special-template.git",
     )
     mock_remote.fetch.assert_called_once_with()