[PATCH] sb/setbuilder: do not include remotes in mailed reports

Chris Johns chrisj at rtems.org
Thu Apr 2 04:52:07 UTC 2020


Hi Gedare,

Thanks for taking a look at this ticket. Comments below..

On 2020-04-02 15:33, Gedare Bloom wrote:
> Closes #3887.
> ---
>   source-builder/sb/reports.py    | 47 ++++++++++++++++++++-------------
>   source-builder/sb/setbuilder.py |  2 +-
>   2 files changed, 29 insertions(+), 20 deletions(-)
> 
> diff --git a/source-builder/sb/reports.py b/source-builder/sb/reports.py
> index ab20671..2f72088 100644
> --- a/source-builder/sb/reports.py
> +++ b/source-builder/sb/reports.py
> @@ -241,13 +241,16 @@ class markdown_formatter(formatter):
>               self.line(self._strong('Remotes:'))
>               self.line('')
>               rc = 1
> -            for r in remotes:
> -                if 'url' in remotes[r]:
> -                    text = remotes[r]['url']
> -                else:
> -                    text = 'no URL found'
> -                self.line('%d. %s: %s' % (rc, r, text))
> -                rc += 1
> +            if not remotes:
> +                self.line('[ removed for email, reply to sender for details ]')
> +            else:
> +                for r in remotes:
> +                    if 'url' in remotes[r]:
> +                        text = remotes[r]['url']
> +                    else:
> +                        text = 'no URL found'
> +                    self.line('%d. %s: %s' % (rc, r, text))
> +                    rc += 1
>               self.line('')
>               self.line(self._strong('Status:'))
>               self.line('')
> @@ -427,14 +430,17 @@ class text_formatter(formatter):
>           if valid:
>               self.line('%s Remotes:' % (self.cini))
>               rc = 0
> -            for r in remotes:
> -                rc += 1
> -                if 'url' in remotes[r]:
> -                    text = remotes[r]['url']
> -                else:
> -                    text = 'no URL found'
> -                text = '%s: %s' % (r, text)
> -                self.line('%s  %2d: %s' % (self.cini, rc, text))
> +            if not remotes:
> +                self.line('[ removed for email, reply to sender for details ]')

Maybe something more generic ...

   [ remotes removed, contact to sender for details ]

?

> +            else:
> +                for r in remotes:
> +                    rc += 1
> +                    if 'url' in remotes[r]:
> +                        text = remotes[r]['url']
> +                    else:
> +                        text = 'no URL found'
> +                    text = '%s: %s' % (r, text)
> +                    self.line('%s  %2d: %s' % (self.cini, rc, text))
>               self.line('%s Status:' % (self.cini))
>               if dirty:
>                   self.line('%s  Repository is dirty' % (self.cini))
> @@ -647,17 +653,20 @@ class report:
>       def release_status(self):
>           self.formatter.release_status(version.string())
>   
> -    def git_status(self):
> +    def git_status(self, sanitize = False):
>           r = git.repo('.', self.opts, self.macros)
> -        self.formatter.git_status(r.valid(), r.dirty(), r.head(), r.remotes())
> +        if sanitize:
> +            self.formatter.git_status(r.valid(), r.dirty(), r.head(), None)
> +        else:
> +            self.formatter.git_status(r.valid(), r.dirty(), r.head(), r.remotes())
>   
> -    def introduction(self, name, intro_text = None):
> +    def introduction(self, name, intro_text = None, sanitize = False):
>           now = datetime.datetime.now().ctime()
>           self.formatter.introduction(name, now, intro_text)
>           if version.released():
>               self.release_status()
>           else:
> -            self.git_status()
> +            self.git_status(sanitize)
>   
>       def epilogue(self, name):
>           self.formatter.epilogue(name)
> diff --git a/source-builder/sb/setbuilder.py b/source-builder/sb/setbuilder.py
> index 7b80817..9367d55 100644
> --- a/source-builder/sb/setbuilder.py
> +++ b/source-builder/sb/setbuilder.py
> @@ -201,7 +201,7 @@ class buildset:
>               if mail:
>                   r = reports.report('text', self.configs,
>                                      copy.copy(opts), copy.copy(macros))
> -                r.introduction(_build.config.file_name())
> +                r.introduction(_build.config.file_name(), sanitize = True)

Should the `sanitize` value be True if self.mail is not None?

Chris

>                   r.generate(_build.config.file_name())
>                   r.epilogue(_build.config.file_name())
>                   self.write_mail_report(r.get_output())
> 


More information about the devel mailing list