Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 491808 | Differences between
and this patch

Collapse All | Expand All

(-)a/irkerhook.py (-32 / +3 lines)
Lines 57-63 class Commit: Link Here
57
        self.rev = None
57
        self.rev = None
58
        self.mail = None
58
        self.mail = None
59
        self.author = None
59
        self.author = None
60
        self.files = None
61
        self.logmsg = None
60
        self.logmsg = None
62
        self.url = None
61
        self.url = None
63
        self.author_date = None
62
        self.author_date = None
Lines 224-230 class GitExtractor(GenericExtractor): Link Here
224
        self.channels = do("git config --get irker.channels")
223
        self.channels = do("git config --get irker.channels")
225
        self.email = do("git config --get irker.email")
224
        self.email = do("git config --get irker.email")
226
        self.tcp = do("git config --bool --get irker.tcp")
225
        self.tcp = do("git config --bool --get irker.tcp")
227
        self.template = '%(bold)s%(project)s:%(reset)s %(green)s%(author)s%(reset)s %(repo)s:%(yellow)s%(branch)s%(reset)s * %(bold)s%(rev)s%(reset)s / %(bold)s%(files)s%(reset)s: %(logmsg)s %(brown)s%(url)s%(reset)s'
226
        self.template = '%(bold)s%(project)s:%(reset)s %(green)s%(author)s%(reset)s %(repo)s:%(yellow)s%(branch)s%(reset)s * %(bold)s%(rev)s%(reset)s: %(logmsg)s %(brown)s%(url)s%(reset)s'
228
        self.tinyifier = do("git config --get irker.tinyifier") or default_tinyifier
227
        self.tinyifier = do("git config --get irker.tinyifier") or default_tinyifier
229
        self.color = do("git config --get irker.color")
228
        self.color = do("git config --get irker.color")
230
        self.urlprefix = do("git config --get irker.urlprefix") or "gitweb"
229
        self.urlprefix = do("git config --get irker.urlprefix") or "gitweb"
Lines 269-277 class GitExtractor(GenericExtractor): Link Here
269
            commit.rev = do("git describe %s 2>/dev/null" % shellquote(commit.commit))
268
            commit.rev = do("git describe %s 2>/dev/null" % shellquote(commit.commit))
270
        if not commit.rev:
269
        if not commit.rev:
271
            commit.rev = commit.commit[:12]
270
            commit.rev = commit.commit[:12]
272
        # Extract the meta-information for the commit
273
        commit.files = do("git diff-tree -r --name-only " + shellquote(commit.commit))
274
        commit.files = " ".join(commit.files.strip().split("\n")[1:])
275
        # Design choice: for git we ship only the first message line, which is
271
        # Design choice: for git we ship only the first message line, which is
276
        # conventionally supposed to be a summary of the commit.  Under
272
        # conventionally supposed to be a summary of the commit.  Under
277
        # other VCSes a different choice may be appropriate.
273
        # other VCSes a different choice may be appropriate.
Lines 292-298 class SvnExtractor(GenericExtractor): Link Here
292
            if tok.startswith("--repository="):
288
            if tok.startswith("--repository="):
293
                self.repository = tok[13:]
289
                self.repository = tok[13:]
294
        self.project = os.path.basename(self.repository)
290
        self.project = os.path.basename(self.repository)
295
        self.template = '%(bold)s%(project)s%(reset)s: %(green)s%(author)s%(reset)s %(repo)s * %(bold)s%(rev)s%(reset)s / %(bold)s%(files)s%(reset)s: %(logmsg)s %(brown)s%(url)s%(reset)s'
291
        self.template = '%(bold)s%(project)s%(reset)s: %(green)s%(author)s%(reset)s %(repo)s * %(bold)s%(rev)s%(reset)s: %(logmsg)s %(brown)s%(url)s%(reset)s'
296
        self.urlprefix = "viewcvs"
292
        self.urlprefix = "viewcvs"
297
        self.load_preferences(os.path.join(self.repository, "irker.conf"))
293
        self.load_preferences(os.path.join(self.repository, "irker.conf"))
298
        self.do_overrides()
294
        self.do_overrides()
Lines 306-312 class SvnExtractor(GenericExtractor): Link Here
306
        commit.rev = "r%s" % self.id
302
        commit.rev = "r%s" % self.id
307
        commit.author = self.svnlook("author")
303
        commit.author = self.svnlook("author")
308
        commit.commit_date = self.svnlook("date").partition('(')[0]
304
        commit.commit_date = self.svnlook("date").partition('(')[0]
309
        commit.files = self.svnlook("dirs-changed").strip().replace("\n", " ")
310
        commit.logmsg = self.svnlook("log").strip()
305
        commit.logmsg = self.svnlook("log").strip()
311
        return commit
306
        return commit
312
    def svnlook(self, info):
307
    def svnlook(self, info):
Lines 350-356 class HgExtractor(GenericExtractor): Link Here
350
        self.channels = ui.config('irker', 'channels')
345
        self.channels = ui.config('irker', 'channels')
351
        self.email = ui.config('irker', 'email')
346
        self.email = ui.config('irker', 'email')
352
        self.tcp = str(ui.configbool('irker', 'tcp'))  # converted to bool again in do_overrides
347
        self.tcp = str(ui.configbool('irker', 'tcp'))  # converted to bool again in do_overrides
353
        self.template = '%(bold)s%(project)s:%(reset)s %(green)s%(author)s%(reset)s %(repo)s:%(yellow)s%(branch)s%(reset)s * %(bold)s%(rev)s%(reset)s / %(bold)s%(files)s%(reset)s: %(logmsg)s %(brown)s%(url)s%(reset)s'
348
        self.template = '%(bold)s%(project)s:%(reset)s %(green)s%(author)s%(reset)s %(repo)s:%(yellow)s%(branch)s%(reset)s * %(bold)s%(rev)s%(reset)s: %(logmsg)s %(brown)s%(url)s%(reset)s'
354
        self.tinyifier = ui.config('irker', 'tinyifier') or default_tinyifier
349
        self.tinyifier = ui.config('irker', 'tinyifier') or default_tinyifier
355
        self.color = ui.config('irker', 'color')
350
        self.color = ui.config('irker', 'color')
356
        self.urlprefix = (ui.config('irker', 'urlprefix') or
351
        self.urlprefix = (ui.config('irker', 'urlprefix') or
Lines 380-388 class HgExtractor(GenericExtractor): Link Here
380
        commit.author_date = \
375
        commit.author_date = \
381
            datetime.datetime.fromtimestamp(ctx.date()[0]).strftime('%Y-%m-%d %H:%M:%S')
376
            datetime.datetime.fromtimestamp(ctx.date()[0]).strftime('%Y-%m-%d %H:%M:%S')
382
        commit.logmsg = ctx.description()
377
        commit.logmsg = ctx.description()
383
        # Extract changed files from status against first parent
384
        st = self.repository.status(ctx.p1().node(), ctx.node())
385
        commit.files = ' '.join(st[0] + st[1] + st[2])
386
        return commit
378
        return commit
387
379
388
def hg_hook(ui, repo, **kwds):
380
def hg_hook(ui, repo, **kwds):
Lines 423-449 def ship(extractor, commit, debug): Link Here
423
            sys.stderr.write("irkerhook.py: could not decode JSON: %s\n" % data)
415
            sys.stderr.write("irkerhook.py: could not decode JSON: %s\n" % data)
424
            raise SystemExit, 1
416
            raise SystemExit, 1
425
417
426
    # Rewrite the file list if too long. The objective here is only
427
    # to be easier on the eyes.
428
    if extractor.cialike \
429
           and extractor.cialike.lower() != "none" \
430
           and len(metadata.files) > int(extractor.cialike):
431
        files = metadata.files.split()
432
        dirs = set([d.rpartition('/')[0] for d in files])
433
        if len(dirs) == 1:
434
            metadata.files = "(%s files)" % (len(files),)
435
        else:
436
            metadata.files = "(%s files in %s dirs)" % (len(files), len(dirs))
437
    # Message reduction.  The assumption here is that IRC can't handle
438
    # lines more than 510 characters long. If we exceed that length, we
439
    # try knocking out the file list, on the theory that for notification
440
    # purposes the commit text is more important.  If it's still too long
441
    # there's nothing much can be done other than ship it expecting the IRC
442
    # server to truncate.
443
    privmsg = unicode(metadata)
418
    privmsg = unicode(metadata)
444
    if len(privmsg) > 510:
445
        metadata.files = ""
446
        privmsg = unicode(metadata)
447
419
448
    # Anti-spamming guard.  It's deliberate that we get maxchannels not from
420
    # Anti-spamming guard.  It's deliberate that we get maxchannels not from
449
    # the user-filtered metadata but from the extractor data - means repo
421
    # the user-filtered metadata but from the extractor data - means repo
450
- 

Return to bug 491808