-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UX - Display the next version because we have now only master version…
… in the metadata.txt
- Loading branch information
Showing
8 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,13 @@ | |
__license__ = "GPL version 3" | ||
__email__ = "[email protected]" | ||
|
||
import subprocess | ||
import time | ||
|
||
from pathlib import Path | ||
|
||
from qgis.utils import pluginMetadata | ||
|
||
|
||
def timing(f): | ||
""" | ||
|
@@ -19,3 +24,53 @@ def wrap(*args): | |
return ret | ||
|
||
return wrap | ||
|
||
|
||
def current_git_hash() -> str: | ||
""" Retrieve the current git hash number of the git repo (first 6 digit). """ | ||
repo_dir = Path(__file__).parent | ||
git_show = subprocess.Popen( | ||
'git rev-parse --short=6 HEAD', | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
shell=True, | ||
cwd=repo_dir, | ||
universal_newlines=True, | ||
encoding='utf8' | ||
) | ||
hash_number = git_show.communicate()[0].partition('\n')[0] | ||
if hash_number == '': | ||
hash_number = 'unknown' | ||
return hash_number | ||
|
||
|
||
def next_git_tag(): | ||
""" Using Git command, trying to guess the next tag. """ | ||
repo_dir = Path(__file__).parent | ||
git_show = subprocess.Popen( | ||
'git describe --tags $(git rev-list --tags --max-count=1)', | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
shell=True, | ||
cwd=repo_dir, | ||
universal_newlines=True, | ||
encoding='utf8' | ||
) | ||
tag = git_show.communicate()[0].partition('\n')[0] | ||
if not tag: | ||
return 'next' | ||
versions = tag.split('.') | ||
text = '{}.{}.{}-pre'.format(versions[0], versions[1], int(versions[2]) + 1) | ||
return text | ||
|
||
|
||
def set_window_title() -> str: | ||
""" Set the window title if on a dev version. """ | ||
version = pluginMetadata('cadastre', 'version') | ||
if version != 'master': | ||
return '' | ||
|
||
# return 'branch {}, commit {}, next {}'.format( | ||
# version, current_git_hash(), next_git_tag()) | ||
|
||
return 'next {}'.format(next_git_tag()) |