Skip to content

Commit

Permalink
Improvements to commit message template
Browse files Browse the repository at this point in the history
Signed-off-by: David Horstmann <[email protected]>
  • Loading branch information
davidhorstmann-arm committed Oct 22, 2024
1 parent 60d0808 commit 5c5b953
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions tools/bin/mbedtls-move-to-framework
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,20 @@ class RepoFileMover:
GIT_EXE = 'git'
FRAMEWORK_DEFAULT_BASE_BRANCH = 'main'

FRAMEWORK_SIDE_TEMPLATE = '''Move files from into the framework
# Note that commit message templates must be comments only
# as git requires that the user edit the template before committing.
FRAMEWORK_SIDE_TEMPLATE = '''# Move files into the framework
# This will be the commit message for the commit in the framework
# repository that adds the files that were moved.
'''

MBEDTLS_SIDE_TEMPLATE = '''Move files out of Mbed TLS
MBEDTLS_SIDE_TEMPLATE = '''# Move files out of Mbed TLS
# This will be the commit message for the commit in the Mbed TLS
# repository that removes the files that were moved.
'''

def __init__(self, source_repo: str, dest_repo: str,
Expand Down Expand Up @@ -148,6 +152,25 @@ class RepoFileMover:

os.remove(template_name)

def commit_template_file_list_src(self) -> str:
template_file_msg = ('# The following files will be deleted'
' (moved to the framework):\n\n')
for src_repo_file in self._file_map.keys():
template_file_msg += '# {f}\n'.format(f=src_repo_file)

template_file_msg += '\n'

return template_file_msg

def commit_template_file_list_dst(self) -> str:
template_file_msg = ('# The following files will be added'
' (moved from Mbed TLS):\n\n')
for dst_repo_file in self._file_map.values():
template_file_msg += '# {f}\n'.format(f=dst_repo_file)

template_file_msg += '\n'

return template_file_msg

def create_dest_repo_branch(self):
"""Create the branch containing the moved files only"""
Expand Down Expand Up @@ -181,7 +204,9 @@ class RepoFileMover:
self.run_git(['mv', f, self._file_map[f]])

# Commit the result
self.commit_interactively_with_template(self.FRAMEWORK_SIDE_TEMPLATE, '-as')
self.commit_interactively_with_template(self.FRAMEWORK_SIDE_TEMPLATE
+ self.commit_template_file_list_dst(),
'-as')

def create_src_repo_branch(self):
"""Create the branch deleting the moved files"""
Expand All @@ -198,7 +223,9 @@ class RepoFileMover:
self.run_git(['rm', f])

# Commit the result
self.commit_interactively_with_template(self.MBEDTLS_SIDE_TEMPLATE, '-as')
self.commit_interactively_with_template(self.MBEDTLS_SIDE_TEMPLATE
+ self.commit_template_file_list_src(),
'-as')

def resolve_deletion_conflicts(self):
file_statuses = self.run_git(['status', '--porcelain'])
Expand Down

0 comments on commit 5c5b953

Please sign in to comment.