Ejemplo n.º 1
0
    def apply(self, g, o: github.Issue.Issue):
        days_since_created = None
        days_since_updated = None
        now = datetime.now()
        if o.state == 'closed':
            return

        if o.created_at is not None:
            days_since_created = (now - o.created_at).days
        else:
            return

        if days_since_created < self.stale_days:
            return

        if o.updated_at is not None:
            days_since_updated = (now - o.updated_at).days
        else:
            return

        if days_since_updated < self.stale_days:
            return

        if HasLabel(o, self.ignore_lifecycle_label) or HasLabel(
                o, self.beginner_friendly_label):
            return

        if HasLabel(o, 'to-be-closed'):
            o.create_comment(
                "This issue is tagged as 'to-be-closed' and hasn't been updated "
                + " in {} days, ".format(days_since_updated) +
                "so we are closing it. You can always reopen this issue if needed."
            )
            o.edit(state='closed')
        elif HasLabel(o, 'stale'):
            o.create_comment(
                "This issue is tagged as 'stale' and hasn't been updated " +
                " in {} days, ".format(days_since_updated) +
                "so we are tagging it as 'to-be-closed'. It will be closed " +
                "in {} days unless updates are made. ".format(self.stale_days)
                + "If you want to remove this label, comment:\n\n" +
                "> @spinnakerbot remove-label to-be-closed")
            AddLabel(g, o, 'to-be-closed')
        else:
            o.create_comment(
                "This issue hasn't been updated in {} days, ".format(
                    days_since_updated) +
                "so we are tagging it as 'stale'. If you want to remove this label, comment:\n\n"
                + "> @spinnakerbot remove-label stale")
            AddLabel(g, o, 'stale')
Ejemplo n.º 2
0
    def apply(self, g, o):
        if o.created_at is None:
            return

        now = datetime.now()
        days_since_created = (now - o.created_at).days

        if days_since_created < self.stale_days:
            return

        if HasLabel(o, 'stale'):
            return

        repo = IssueRepo(o)

        newest_date = o.created_at
        for e in o.get_events():
            if e.created_at > newest_date:
                newest_date = e.created_at

        delta = now - newest_date
        if delta.days >= self.stale_days:
            self.logging.info(
                "Tagging {} as stale after {} days since last activity".format(
                    o.url, delta.days))
            AddLabel(g, o, 'stale')
Ejemplo n.º 3
0
    def apply(self, g, o):
        now = datetime.now()
        delta = now - o.created_at
        # exit early to avoid listing all events
        if delta.days < self.stale_days:
            return

        if HasLabel(o, 'stale'):
            return

        repo = IssueRepo(o)

        newest_date = o.created_at
        for e in o.get_events():
            if e.created_at > newest_date:
                newest_date = e.created_at

        delta = now - newest_date
        if delta.days >= self.stale_days:
            self.logging.info(
                "Tagging {} as stale after {} days since last activity".format(
                    o.url, delta.days))
            AddLabel(g, o, 'stale')