xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Ticket #2967: trac-hub.patch

File trac-hub.patch, 3.0 KB (added by Antoine Martin, 8 months ago)

remove email addresses from tickets, remove dependency on unused mysql backend, increase delay to prevent hitting the github API rate limits, don't post empty comments, fix wiki links

  • Gemfile

    diff --git a/Gemfile b/Gemfile
    index fb2b575..0c9eefa 100644
    a b  
    11source 'https://rubygems.org'
    22gem 'sequel'
    33gem 'sqlite3'
    4 gem 'mysql2'
    54gem 'rest-client'
    65
    76
  • Gemfile.lock

    diff --git a/Gemfile.lock b/Gemfile.lock
    index 43a91d4..b68a3b6 100644
    a b GEM 
    88    mime-types (3.1)
    99      mime-types-data (~> 3.2015)
    1010    mime-types-data (3.2016.0521)
    11     mysql2 (0.4.6)
    1211    netrc (0.11.0)
    1312    rest-client (2.0.2)
    1413      http-cookie (>= 1.0.2, < 2.0)
    PLATFORMS 
    2423  ruby
    2524
    2625DEPENDENCIES
    27   mysql2
    2826  rest-client
    2927  sequel
    3028  sqlite3
    3129
    3230BUNDLED WITH
    33    1.15.1
     31   2.1.4
  • trac-hub

    diff --git a/trac-hub b/trac-hub
    index 82f8947..9b12510 100755
    a b class Migrator 
    8080
    8181  # returns the author mail if found, otherwise author itself
    8282  def trac_mail(author)
    83     return @trac_mails_cache[author] if @trac_mails_cache.has_key?(author)
     83    #return @trac_mails_cache[author] if @trac_mails_cache.has_key?(author)
    8484    # tries to retrieve the email from trac db
    85     data = @trac.sessions.select(:value).where('name = "email" AND sid = ?', author)
    86     return (@trac_mails_cache[author] = data.first[:value]) if data.count == 1
     85    #data = @trac.sessions.select(:value).where('name = "email" AND sid = ?', author)
     86    #return (@trac_mails_cache[author] = data.first[:value]) if data.count == 1
    8787    return (@trac_mails_cache[author] = author) # not found
    8888  end
    8989
    class Migrator 
    135135
    136136      if @safetychecks
    137137        while response["status"] == "pending"
    138           sleep 0.1
     138          sleep 0.7
    139139          $logger.info("Checking import status: #{response['id']}")
    140140          response = JSON.parse(RestClient.get(response['url'], {
    141141            "Authorization" => "token #{@token}",
    class Migrator 
    258258
    259259    text = ""
    260260    text += "\n___\n" if append
    261     text += "#### #{time.strftime("%Y-%m-%d %H:%M:%S")}: #{author} "
     261    time_author = "#### #{time.strftime("%Y-%m-%d %H:%M:%S")}: #{author} "
     262    text += time_author
    262263
    263264    case kind
    264265      when 'owner', 'status', 'title', 'resolution', 'priority', 'component', 'type', 'severity', 'platform'
    class Migrator 
    313314        return nil
    314315    end
    315316
     317    if text.length==time_author.length
     318      print "empty comment!"
     319      return nil
     320    end
    316321    return {
    317322      "body" => text,
    318323      "created_at" => format_time(meta[:time]),
    class Migrator 
    353358    str.gsub!(/\[changeset:(\d+)\]/)     { map_changeset(Regexp.last_match[1]) }
    354359    # Ticket
    355360    str.gsub!(/ticket:(\d+)/, '#\1')
     361    # Wiki:
     362    if m = str.match(/\[.*\/wiki\/(\w*)(\/\w*)?(\/\w*)?(#\w*)?\]/)
     363      s = m[0]
     364      s.gsub!(/#.*/, '')
     365      s.gsub!(/^\[/, '')
     366      s.gsub!(/\]$/, '')
     367      l = s.dup
     368      s.gsub!(/\//, '-')
     369      s.gsub!(/-wiki-/, '../wiki/')
     370      l.gsub!(/\//, ' ')
     371      l.gsub!(/ wiki /, '')
     372      s = "["+l+"]("+s+")"
     373      str.gsub!(/\[\/wiki\/(\w*)(\/\w*)?(\/\w*)?(#\w*)?\]/, s)
     374    end
    356375    # set the body as a comment
    357376    str.gsub!("\n", "\n> ")
    358377    str = "> #{str}"