guyzmo / git-repo

Git-Repo: CLI utility to manage git services from your workspace
https://webchat.freenode.net/?channels=#git-repo
Other
842 stars 85 forks source link

Provide a template system for MR title and message #150

Closed megawubs closed 7 years ago

megawubs commented 7 years ago

For example I'm working in a gitlab environment where issues are leading and I want to have the text Resovle: "[issue title]" as the title by default andcloses #{issue-number} as the message. For this to work, we need some sort of templating system with simple if/then and some variables and string regex checks

Variables (from the top of my head):

Example pseudo template:

if(BRANCH_NAME starts with numbers and then a dash*) //it's probably the issue number!
closes #[regex-match]
endif
guyzmo commented 7 years ago

I suggest to use jinja to do the templating.

Something like that:

{% title, *body = repository.commit().message.split('\n') %}
### Title
{{ title }}

### Body
{{ '\n'.join(body) }}

{% match = re.match(repository.head.name, r'^(?P<branch_commit>\d+).*') %}
{% if match %}
closes {{ match.groupdict()['branch_commit'] }}
{% endif %}
guyzmo commented 7 years ago

cf #122