Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

STCC-241 remove build nr increment #168

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion run
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ if not os.path.isdir(jython_home_dir):
if not os.path.isfile(jython_exec_path):
helpers.error("Jython script path '%s' must exist." % jython_exec_path.replace(".bat", "[.bat]"))

helpers.inject_git_commmit_hook()

env = os.environ
env['JYTHONPATH'] = jython_path if sys.platform != 'win32' else jython_path.replace(":", ";")
Expand Down
1 change: 0 additions & 1 deletion run_dbg
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ if not os.path.isdir(jython_home_dir):
if not os.path.isfile(jython_exec_path):
helpers.error("Jython script path '%s' must exist." % jython_exec_path.replace(".bat", "[.bat]"))

helpers.inject_git_commmit_hook()

env = os.environ
env['JYTHONPATH'] = jython_path if sys.platform != 'win32' else jython_path.replace(":", ";")
Expand Down
85 changes: 0 additions & 85 deletions src/scratchtocatrobat/tools/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,91 +245,6 @@ def _setup_configuration(config_file_path = None):
config = config_env
return config

def inject_git_commmit_hook():
git_dir = os.path.join(APP_PATH, ".git")
if not os.path.isdir(git_dir): # abort, this seems to be no valid git repository...
return

hook_dir_path = os.path.join(git_dir, "hooks")
make_dir_if_not_exists(hook_dir_path)
hook_path = os.path.join(hook_dir_path, "pre-commit")

config_default_file_path = os.path.normpath(os.path.join(CFG_PATH, CFG_DEFAULT_FILE_NAME))
config_custom_env_file_path = os.path.normpath(os.path.join(CFG_PATH, CFG_CUSTOM_ENV_FILE_NAME))

def formatted_shell_script_code(content):
lines = content.split('\n')
formatted_lines = []
ignore_line_indentation = False
python_code_line_indentation = -1
update_python_code_line_indentation = False
for line in lines[1:]: # skip first line
if "<<EOF" in line:
ignore_line_indentation = True
elif "EOF" in line:
ignore_line_indentation = False
if update_python_code_line_indentation:
index = 0
for c in line:
if c is not " ":
break
index += 1
update_python_code_line_indentation = False
python_code_line_indentation = index
if ignore_line_indentation and python_code_line_indentation != -1:
line = line[python_code_line_indentation:]
else:
line = line.lstrip()
formatted_lines.append(line + '\n')
if ignore_line_indentation and python_code_line_indentation == -1:
update_python_code_line_indentation = True
return ''.join(formatted_lines)

shell_script_code = """
#!/bin/sh
PROJECT_DIR=`pwd`
CONFIG_DEFAULT_FILE_PATH="%s"
CONFIG_CUSTOM_ENV_FILE_PATH="%s"
branchName=`/usr/bin/env git symbolic-ref HEAD | sed -e 's,.*/\\(.*\\),\\1,'`
gitCount=`/usr/bin/env git rev-list $branchName |wc -l | sed 's/^ *//;s/ *$//'`
buildNumber="$((gitCount + 1))"

/usr/bin/env python2 - <<EOF
def update_build_number(config_file_name, number):
# TODO: regex...
content = open(config_file_name).read()
search_str = "build_number:"
start_pos = content.find(search_str)
if start_pos == -1:
return # not found...
else:
start_pos += len(search_str)
end_pos = content.find("\\n", start_pos)
old_build_no_str = "{0}{1}".format(search_str, content[start_pos:end_pos])
new_build_no_str = "{0} {1}".format(search_str, number)
content = content.replace(old_build_no_str, new_build_no_str)
with open(config_file_name, 'w') as config_file:
config_file.write(content)
update_build_number("${CONFIG_DEFAULT_FILE_PATH}", "${buildNumber}")
import os
if os.path.isfile("${CONFIG_CUSTOM_ENV_FILE_PATH}"):
update_build_number("${CONFIG_CUSTOM_ENV_FILE_PATH}", "${buildNumber}")
EOF

# Add modified config file to the staging area
# NOTE: Only the default config file is part of the repository!
cd ${PROJECT_DIR}
if [ -f "$CONFIG_DEFAULT_FILE_PATH" ]; then
/usr/bin/env git add ${CONFIG_DEFAULT_FILE_PATH}
fi
exit 0
""" % (config_default_file_path, config_custom_env_file_path)

formatted_shell_script_code = formatted_shell_script_code(shell_script_code)
with open(hook_path, "w") as shell_script_file:
shell_script_file.write(formatted_shell_script_code)
os.chmod(hook_path, 0755)

config = _setup_configuration()

JYTHON_RESPECT_JAVA_ACCESSIBILITY_PROPERTY = "python.security.respectJavaAccessibility"
Expand Down