Repository: packit/packit
Issue: packit dropped leading zeros in version numbers

I am working on a project with version '2020.09.24'. When I run propose-update, packit cut the version to '2020.9.24' and failed to checkout the new version.

Packit is run from git repo at 790b01a3 on Fedora 32

debug output:
```
10:53:14.640 config.py         DEBUG  Loading user config from directory: /home/cheese/.config
10:53:14.640 config.py         DEBUG  Trying to load user config from: /home/cheese/.config/.packit.yaml
10:53:14.640 config.py         DEBUG  Trying to load user config from: /home/cheese/.config/.packit.yml
10:53:14.640 config.py         DEBUG  Trying to load user config from: /home/cheese/.config/.packit.json
10:53:14.640 config.py         DEBUG  Trying to load user config from: /home/cheese/.config/packit.yaml
10:53:14.640 config.py         DEBUG  Trying to load user config from: /home/cheese/.config/packit.yml
10:53:14.640 config.py         DEBUG  Trying to load user config from: /home/cheese/.config/packit.json
10:53:14.644 config.py         DEBUG  Loaded config: Config(debug='False', fas_user='None', keytab_path='None', command_handler='RunCommandType.local', command_handler_work_dir='/sandcastle', command_handler_pvc_env_var='SANDCASTLE_PVC', command_handler_image_reference='docker.io/usercont/sandcastle', command_handler_k8s_namespace='myproject')
10:53:14.644 logging.py        DEBUG  Logging set to DEBUG
10:53:14.645 packit_base.py    DEBUG  Packit 0.16.0 is being used.
10:53:14.645 types.py          DEBUG  Input is a directory: /run/media/cheese/cheesenotes/deepin/deepin-icon-theme
10:53:14.645 local_project.py  DEBUG  Arguments received in the init method of the LocalProject class: 
git_repo: None
working_dir: /run/media/cheese/cheesenotes/deepin/deepin-icon-theme
ref: None
git_project: None
git_service: None
git_url: 
full_name: 
namespace: 
repo_name: 
offline: False
refresh True
remote: None
pr_id: None

10:53:14.645 local_project.py  DEBUG  `working_dir` is set and `git_repo` is not: let's discover...
10:53:14.645 local_project.py  DEBUG  It's a git repo!
10:53:14.646 local_project.py  DEBUG  Parsed ref 'master' from the repo <git.Repo "/run/media/cheese/cheesenotes/deepin/deepin-icon-theme/.git">.
10:53:14.647 local_project.py  DEBUG  Parsed remote url 'https://github.com/linuxdeepin/deepin-icon-theme.git' from the repo <git.Repo "/run/media/cheese/cheesenotes/deepin/deepin-icon-theme/.git">.
10:53:14.647 local_project.py  DEBUG  Parsed namespace and repo name (linuxdeepin, deepin-icon-theme) from url 'https://github.com/linuxdeepin/deepin-icon-theme.git'.
10:53:14.647 local_project.py  DEBUG  Parsed full repo name 'linuxdeepin/deepin-icon-theme'.
10:53:14.647 package_config.py DEBUG  Local package config found: /run/media/cheese/cheesenotes/deepin/deepin-icon-theme/.packit.yaml
10:53:14.733 package_config.py DEBUG  Local spec files found: [PosixPath('rpm/deepin-icon-theme.spec')]. Taking: rpm/deepin-icon-theme.spec
10:53:14.733 package_config.py DEBUG  Package config:
{
    "specfile_path": "rpm/deepin-icon-theme.spec",
    "synced_files": [
        "rpm/deepin-icon-theme.spec",
        ".packit.yaml"
    ],
    "upstream_ref": "2020.09.24",
    "upstream_package_name": "deepin-icon-theme",
    "downstream_package_name": "deepin-icon-theme",
    "actions": {
        "fix-spec-file": "bash -c \\"sed -i -r \\\\\\"s/Version:(\\\\s*)\\\\S*/Version:\\\\1${PACKIT_PROJECT_VERSION}/\\\\\\" rpm/deepin-icon-theme.spec\\"\\n"
    }
}
10:53:14.736 package_config.py DEBUG  PackageConfig(config_file_path='.packit.yaml', specfile_path='rpm/deepin-icon-theme.spec', synced_files='SyncFilesConfig([SyncFilesItem(src=rpm/deepin-icon-theme.spec, dest=rpm/deepin-icon-theme.spec), SyncFilesItem(src=.packit.yaml, dest=.packit.yaml)])', jobs='[JobConfig(job=JobType.tests, trigger=JobConfigTriggerType.pull_request, meta=JobMetadataConfig(targets={'fedora-stable'}, timeout=7200, owner=None, project=None, dist_git_branches=set(), branch=None, scratch=False, list_on_homepage=False, preserve_project=False, additional_packages=[], additional_repos=[]), config_file_path='.packit.yaml', specfile_path='rpm/deepin-icon-theme.spec', synced_files='SyncFilesConfig([SyncFilesItem(src=rpm/deepin-icon-theme.spec, dest=rpm/deepin-icon-theme.spec), SyncFilesItem(src=.packit.yaml, dest=.packit.yaml)])', dist_git_namespace='rpms', upstream_project_url='None', upstream_package_name='deepin-icon-theme', downstream_project_url='https://src.fedoraproject.org/rpms/deepin-icon-theme.git', downstream_package_name='deepin-icon-theme', dist_git_base_url='https://src.fedoraproject.org/', create_tarball_command='None', current_version_command='['git', 'describe', '--abbrev=0', '--tags', '--match', '*']', actions='{<ActionName.fix_spec: 'fix-spec-file'>: 'bash -c "sed -i -r \\\\"s/Version:(\\\\s*)\\\\S*/Version:\\\\1${PACKIT_PROJECT_VERSION}/\\\\" rpm/deepin-icon-theme.spec"\\n'}', upstream_ref='2020.09.24', allowed_gpg_keys='None', create_pr='True', spec_source_id='Source0', upstream_tag_template='{version}', patch_generation_ignore_paths='[]'), JobConfig(job=JobType.propose_downstream, trigger=JobConfigTriggerType.release, meta=JobMetadataConfig(targets=set(), timeout=7200, owner=None, project=None, dist_git_branches={'fedora-all'}, branch=None, scratch=False, list_on_homepage=False, preserve_project=False, additional_packages=[], additional_repos=[]), config_file_path='.packit.yaml', specfile_path='rpm/deepin-icon-theme.spec', synced_files='SyncFilesConfig([SyncFilesItem(src=rpm/deepin-icon-theme.spec, dest=rpm/deepin-icon-theme.spec), SyncFilesItem(src=.packit.yaml, dest=.packit.yaml)])', dist_git_namespace='rpms', upstream_project_url='None', upstream_package_name='deepin-icon-theme', downstream_project_url='https://src.fedoraproject.org/rpms/deepin-icon-theme.git', downstream_package_name='deepin-icon-theme', dist_git_base_url='https://src.fedoraproject.org/', create_tarball_command='None', current_version_command='['git', 'describe', '--abbrev=0', '--tags', '--match', '*']', actions='{<ActionName.fix_spec: 'fix-spec-file'>: 'bash -c "sed -i -r \\\\"s/Version:(\\\\s*)\\\\S*/Version:\\\\1${PACKIT_PROJECT_VERSION}/\\\\" rpm/deepin-icon-theme.spec"\\n'}', upstream_ref='2020.09.24', allowed_gpg_keys='None', create_pr='True', spec_source_id='Source0', upstream_tag_template='{version}', patch_generation_ignore_paths='[]')]', dist_git_namespace='rpms', upstream_project_url='None', upstream_package_name='deepin-icon-theme', downstream_project_url='https://src.fedoraproject.org/rpms/deepin-icon-theme.git', downstream_package_name='deepin-icon-theme', dist_git_base_url='https://src.fedoraproject.org/', create_tarball_command='None', current_version_command='['git', 'describe', '--abbrev=0', '--tags', '--match', '*']', actions='{<ActionName.fix_spec: 'fix-spec-file'>: 'bash -c "sed -i -r \\\\"s/Version:(\\\\s*)\\\\S*/Version:\\\\1${PACKIT_PROJECT_VERSION}/\\\\" rpm/deepin-icon-theme.spec"\\n'}', upstream_ref='2020.09.24', allowed_gpg_keys='None', create_pr='True', spec_source_id='Source0', upstream_tag_template='{version}', patch_generation_ignore_paths='[]')
Input directory is an upstream repository.
Syncing from the following branches: master
10:53:14.746 repo.py           DEBUG  Provided input 'https://github.com/linuxdeepin/deepin-icon-theme.git' is an url.
Won't be doing kinit, no credentials provided.
10:53:14.747 local_project.py  DEBUG  Arguments received in the init method of the LocalProject class: 
git_repo: None
working_dir: /run/media/cheese/cheesenotes/pkgdb/deepin/deepin-icon-theme/
ref: 
git_project: PagureProject(namespace="rpms", repo="deepin-icon-theme")
git_service: None
git_url: https://src.fedoraproject.org/rpms/deepin-icon-theme.git
full_name: 
namespace: rpms
repo_name: deepin-icon-theme
offline: False
refresh True
remote: 
pr_id: None

10:53:14.747 local_project.py  DEBUG  Parsed full repo name 'rpms/deepin-icon-theme'.
10:53:14.747 local_project.py  DEBUG  `working_dir` is set and `git_repo` is not: let's discover...
10:53:14.747 local_project.py  DEBUG  It's a git repo!
10:53:14.748 local_project.py  DEBUG  Parsed service PagureService(instance_url='https://src.fedoraproject.org') from the project PagureProject(namespace="rpms", repo="deepin-icon-theme").
10:53:14.748 local_project.py  DEBUG  Parsed ref '2020.9.2-master-update' from the repo <git.Repo "/run/media/cheese/cheesenotes/pkgdb/deepin/deepin-icon-theme/.git">.
10:53:14.788 package_config.py DEBUG  Local package config found: /run/media/cheese/cheesenotes/pkgdb/deepin/deepin-icon-theme/.packit.yaml
10:53:14.791 package_config.py DEBUG  Local spec files found: [PosixPath('deepin-icon-theme.spec')]. Taking: deepin-icon-theme.spec
10:53:14.791 package_config.py DEBUG  Package config:
{
    "specfile_path": "rpm/deepin-icon-theme.spec",
    "synced_files": [
        "rpm/deepin-icon-theme.spec",
        ".packit.yaml"
    ],
    "upstream_ref": "2020.09.02",
    "upstream_package_name": "deepin-icon-theme",
    "downstream_package_name": "deepin-icon-theme",
    "actions": {
        "fix-spec-file": "bash -c \\"sed -i -r \\\\\\"s/Version:(\\\\s*)\\\\S*/Version:\\\\1${PACKIT_PROJECT_VERSION}/\\\\\\" rpm/deepin-icon-theme.spec\\"\\n"
    }
}
10:53:14.795 package_config.py DEBUG  PackageConfig(config_file_path='.packit.yaml', specfile_path='rpm/deepin-icon-theme.spec', synced_files='SyncFilesConfig([SyncFilesItem(src=rpm/deepin-icon-theme.spec, dest=rpm/deepin-icon-theme.spec), SyncFilesItem(src=.packit.yaml, dest=.packit.yaml)])', jobs='[JobConfig(job=JobType.tests, trigger=JobConfigTriggerType.pull_request, meta=JobMetadataConfig(targets={'fedora-stable'}, timeout=7200, owner=None, project=None, dist_git_branches=set(), branch=None, scratch=False, list_on_homepage=False, preserve_project=False, additional_packages=[], additional_repos=[]), config_file_path='.packit.yaml', specfile_path='rpm/deepin-icon-theme.spec', synced_files='SyncFilesConfig([SyncFilesItem(src=rpm/deepin-icon-theme.spec, dest=rpm/deepin-icon-theme.spec), SyncFilesItem(src=.packit.yaml, dest=.packit.yaml)])', dist_git_namespace='rpms', upstream_project_url='None', upstream_package_name='deepin-icon-theme', downstream_project_url='https://src.fedoraproject.org/rpms/deepin-icon-theme.git', downstream_package_name='deepin-icon-theme', dist_git_base_url='https://src.fedoraproject.org/', create_tarball_command='None', current_version_command='['git', 'describe', '--abbrev=0', '--tags', '--match', '*']', actions='{<ActionName.fix_spec: 'fix-spec-file'>: 'bash -c "sed -i -r \\\\"s/Version:(\\\\s*)\\\\S*/Version:\\\\1${PACKIT_PROJECT_VERSION}/\\\\" rpm/deepin-icon-theme.spec"\\n'}', upstream_ref='2020.09.02', allowed_gpg_keys='None', create_pr='True', spec_source_id='Source0', upstream_tag_template='{version}', patch_generation_ignore_paths='[]'), JobConfig(job=JobType.propose_downstream, trigger=JobConfigTriggerType.release, meta=JobMetadataConfig(targets=set(), timeout=7200, owner=None, project=None, dist_git_branches={'fedora-all'}, branch=None, scratch=False, list_on_homepage=False, preserve_project=False, additional_packages=[], additional_repos=[]), config_file_path='.packit.yaml', specfile_path='rpm/deepin-icon-theme.spec', synced_files='SyncFilesConfig([SyncFilesItem(src=rpm/deepin-icon-theme.spec, dest=rpm/deepin-icon-theme.spec), SyncFilesItem(src=.packit.yaml, dest=.packit.yaml)])', dist_git_namespace='rpms', upstream_project_url='None', upstream_package_name='deepin-icon-theme', downstream_project_url='https://src.fedoraproject.org/rpms/deepin-icon-theme.git', downstream_package_name='deepin-icon-theme', dist_git_base_url='https://src.fedoraproject.org/', create_tarball_command='None', current_version_command='['git', 'describe', '--abbrev=0', '--tags', '--match', '*']', actions='{<ActionName.fix_spec: 'fix-spec-file'>: 'bash -c "sed -i -r \\\\"s/Version:(\\\\s*)\\\\S*/Version:\\\\1${PACKIT_PROJECT_VERSION}/\\\\" rpm/deepin-icon-theme.spec"\\n'}', upstream_ref='2020.09.02', allowed_gpg_keys='None', create_pr='True', spec_source_id='Source0', upstream_tag_template='{version}', patch_generation_ignore_paths='[]')]', dist_git_namespace='rpms', upstream_project_url='None', upstream_package_name='deepin-icon-theme', downstream_project_url='https://src.fedoraproject.org/rpms/deepin-icon-theme.git', downstream_package_name='deepin-icon-theme', dist_git_base_url='https://src.fedoraproject.org/', create_tarball_command='None', current_version_command='['git', 'describe', '--abbrev=0', '--tags', '--match', '*']', actions='{<ActionName.fix_spec: 'fix-spec-file'>: 'bash -c "sed -i -r \\\\"s/Version:(\\\\s*)\\\\S*/Version:\\\\1${PACKIT_PROJECT_VERSION}/\\\\" rpm/deepin-icon-theme.spec"\\n'}', upstream_ref='2020.09.02', allowed_gpg_keys='None', create_pr='True', spec_source_id='Source0', upstream_tag_template='{version}', patch_generation_ignore_paths='[]')
10:53:14.795 base_git.py       DEBUG  Running ActionName.post_upstream_clone hook.
10:53:14.795 base_git.py       DEBUG  Running ActionName.post_upstream_clone.
10:53:14.795 base_git.py       DEBUG  Running default implementation for ActionName.post_upstream_clone.
Version in upstream registries is '2020.09.24'.
Version in spec file is '2020.09.24'.
Picking version <Version('2020.9.24')> found in spec file.
Checking out upstream version 2020.9.24.
ERROR    Cannot checkout release tag: GitCommandError(['git', 'checkout', '2020.9.24'], 1, b"error: pathspec '2020.9.24' did not match any file(s) known to git", b'').
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/packit/local_project.py", line 423, in checkout_release
    self.git_repo.git.checkout(version)
  File "/usr/lib/python3.8/site-packages/git/cmd.py", line 545, in <lambda>
    return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
  File "/usr/lib/python3.8/site-packages/git/cmd.py", line 1014, in _call_process
    return self.execute(call, **exec_kwargs)
  File "/usr/lib/python3.8/site-packages/git/cmd.py", line 825, in execute
    raise GitCommandError(command, status, stderr_value, stdout_value)
git.exc.GitCommandError: Cmd('git') failed due to: exit code(1)
  cmdline: git checkout 2020.9.24
  stderr: 'error: pathspec '2020.9.24' did not match any file(s) known to git'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/packit/cli/utils.py", line 62, in covered_func
    func(config=config, *args, **kwargs)
  File "/usr/lib/python3.8/site-packages/packit/cli/update.py", line 129, in update
    api.sync_release(
  File "/usr/lib/python3.8/site-packages/packit/api.py", line 186, in sync_release
    self.up.local_project.checkout_release(upstream_tag)
  File "/usr/lib/python3.8/site-packages/packit/local_project.py", line 425, in checkout_release
    raise PackitException(f"Cannot checkout release tag: {ex!r}.")
packit.exceptions.PackitException: Cannot checkout release tag: GitCommandError(['git', 'checkout', '2020.9.24'], 1, b"error: pathspec '2020.9.24' did not match any file(s) known to git", b'').

```

Changed files:
packit/upstream.py

diff --git a/packit/upstream.py b/packit/upstream.py
index c16a272b..745dd18a 100644
--- a/packit/upstream.py
+++ b/packit/upstream.py
@@ -253,16 +253,16 @@ class Upstream(PackitRepositoryBase):
         Return version of the latest release available: prioritize bigger from upstream
         package repositories or the version in spec
         """
-        ups_ver = version.parse(self.get_latest_released_version() or "")
-        spec_ver = version.parse(self.get_specfile_version())
+        ups_ver = self.get_latest_released_version() or ""
+        spec_ver = self.get_specfile_version()
 
-        if ups_ver > spec_ver:
+        if version.parse(ups_ver) > version.parse(spec_ver):
             logger.warning(f"Version {spec_ver!r} in spec file is outdated.")
             logger.info(f"Picking version {ups_ver!r} from upstream registry.")
-            return str(ups_ver)
+            return ups_ver
 
         logger.info(f"Picking version {spec_ver!r} found in spec file.")
-        return str(spec_ver)
+        return spec_ver
 
     def get_current_version(self) -> str:
         """