Skip to content

Commit

Permalink
Update of the --production logic in order to autoupdate .travis.yml
Browse files Browse the repository at this point in the history
Signed-off-by: funilrys <contact@funilrys.com>
  • Loading branch information
funilrys committed Jun 17, 2018
1 parent 39c5ec6 commit 36c7b0b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
2 changes: 1 addition & 1 deletion PyFunceble/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
from PyFunceble.production import Production

CURRENT_DIRECTORY = getcwd() + directory_separator
VERSION = "0.82.1.dev-beta"
VERSION = "0.82.2.dev-beta"

CONFIGURATION_FILENAME = ".PyFunceble.yaml"

Expand Down
36 changes: 32 additions & 4 deletions PyFunceble/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,6 @@ def __init__(self, extern=False):
self.current_version[0]
)

Dict(self.data_version_yaml).to_yaml(
PyFunceble.CURRENT_DIRECTORY + "version.yaml"
)

self._update_docs(PyFunceble.CURRENT_DIRECTORY + "README.md")
self._update_docs(
PyFunceble.CURRENT_DIRECTORY
Expand All @@ -132,6 +128,11 @@ def __init__(self, extern=False):
+ "index.rst"
)
self._update_setup_py()
self._update_travis_yml()

Dict(self.data_version_yaml).to_yaml(
PyFunceble.CURRENT_DIRECTORY + "version.yaml"
)

message = Fore.GREEN + Style.BRIGHT + "We are ready to ship!! \n"
message += Fore.CYAN + "Please do not touch version.yaml nor setup.py (version update)" # pylint: disable=line-too-long
Expand Down Expand Up @@ -272,3 +273,30 @@ def _update_setup_py(self):
to_update = Regex(to_update, regex, replace_with=replacement).replace()

File(setup_py_path).write(to_update, overwrite=True)

def _update_travis_yml(self):
"""
This method will update .travis.yml according to current branch.
"""

travis_yml_path = PyFunceble.CURRENT_DIRECTORY + ".travis.yml"

if self._is_dev_version():
regexes = {
"pip3 install pyfunceble-dev": r"pip3\sinstall\spyfunceble.*",
"pip-autoremove pyfunceble-dev ": r"pip-autoremove\spyfunceble[a-z-_]+\s",
}
elif self._is_master_version():
regexes = {
"pip3 install pyfunceble": r"pip3\sinstall\spyfunceble.*",
"pip-autoremove pyfunceble ": r"pip-autoremove\spyfunceble[a-z-_]+\s",
}
else:
raise Exception("Please switch to `dev` or `master` branch.")

to_update = File(travis_yml_path).read()

for replacement, regex in regexes.items():
to_update = Regex(to_update, regex, replace_with=replacement).replace()

File(travis_yml_path).write(to_update, overwrite=True)
2 changes: 1 addition & 1 deletion version.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
current_version: 0.82.1.dev-beta
current_version: 0.82.2.dev-beta
deprecated: [0.0.0, 0.0.1, 0.65.0, 0.67.1, 0.68.0, 0.69.3, 0.69.5, 0.70.4, 0.71.2,
0.72.7, 0.73.1, 0.74.5, 0.75.1, 0.76.2, 0.77.0, 0.78.0, 0.79.1, 0.80.9, 0.81.8]
force_update:
Expand Down

0 comments on commit 36c7b0b

Please sign in to comment.