You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by je...@apache.org on 2014/07/25 13:09:14 UTC
[04/16] git commit: [#7510] Script to prepare exported tickets for
importing. Fixes for solr indexing.
[#7510] Script to prepare exported tickets for importing. Fixes for solr indexing.
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/fdefd40d
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/fdefd40d
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/fdefd40d
Branch: refs/heads/je/42cc_7524
Commit: fdefd40d5b309d75ff3968c974829461f77fde17
Parents: 27e3d6a
Author: Alexander Luberg <al...@slashdotmedia.com>
Authored: Thu Jul 10 22:34:15 2014 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Tue Jul 22 16:24:24 2014 +0000
----------------------------------------------------------------------
Allura/allura/lib/markdown_extensions.py | 2 +-
Allura/allura/tasks/index_tasks.py | 2 +
scripts/prepare-allura-tickets-for-import.py | 72 +++++++++++++++++++++++
3 files changed, 75 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/fdefd40d/Allura/allura/lib/markdown_extensions.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/markdown_extensions.py b/Allura/allura/lib/markdown_extensions.py
index d2922c5..055a74a 100644
--- a/Allura/allura/lib/markdown_extensions.py
+++ b/Allura/allura/lib/markdown_extensions.py
@@ -335,7 +335,7 @@ class ForgeLinkPattern(markdown.inlinepatterns.LinkPattern):
classes = 'alink'
href = link
shortlink = M.Shortlink.lookup(link)
- if shortlink and not getattr(shortlink.ref.artifact, 'deleted', False):
+ if shortlink and shortlink.ref and not getattr(shortlink.ref.artifact, 'deleted', False):
href = shortlink.url
if getattr(shortlink.ref.artifact, 'is_closed', False):
classes += ' strikethrough'
http://git-wip-us.apache.org/repos/asf/allura/blob/fdefd40d/Allura/allura/tasks/index_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tasks/index_tasks.py b/Allura/allura/tasks/index_tasks.py
index 3daf4ec..2248855 100644
--- a/Allura/allura/tasks/index_tasks.py
+++ b/Allura/allura/tasks/index_tasks.py
@@ -73,6 +73,8 @@ def add_artifacts(ref_ids, update_solr=True, update_refs=True, solr_hosts=None):
for ref in M.ArtifactReference.query.find(dict(_id={'$in': ref_ids})):
try:
artifact = ref.artifact
+ if not artifact:
+ continue
s = artifact.solarize()
if s is None:
continue
http://git-wip-us.apache.org/repos/asf/allura/blob/fdefd40d/scripts/prepare-allura-tickets-for-import.py
----------------------------------------------------------------------
diff --git a/scripts/prepare-allura-tickets-for-import.py b/scripts/prepare-allura-tickets-for-import.py
new file mode 100644
index 0000000..da436d1
--- /dev/null
+++ b/scripts/prepare-allura-tickets-for-import.py
@@ -0,0 +1,72 @@
+#!/usr/bin/env python
+from itertools import tee, izip
+import json
+import git
+
+
+filename = "/Users/alexl/Code/allura-backup-2014-07-09-183025/tickets.json" # Absolute path to exported tickets.json
+output = "/Users/alexl/Code/allura-backup-2014-07-09-183025/updated_tickets_100.json" # Absolute path to the output
+
+gitrepository = "/Users/alexl/Code/allura-git" # Path to allura repository
+g = git.Git(gitrepository)
+
+reviews = ['code-review', 'design-review']
+backlog = ['open', 'in-progress', 'validation', 'review', 'blocked']
+released = ['closed', 'wontfix', 'invalid']
+
+with open(filename, 'r') as json_file:
+ data = json.loads(json_file.read())
+
+
+def pairwise(iterable):
+ """s -> (s0,s1), (s1,s2), (s2, s3), ..."""
+ a, b = tee(iterable)
+ next(b, None)
+ return izip(a, b)
+
+
+tags = ['asf_release_1.0.0', 'asf_release_1.0.0-RC1', 'asf_release_1.0.1', 'asf_release_1.1.0']
+
+tag_log = dict()
+for tag1, tag2 in pairwise(tags):
+ log = g.log('%s...%s' % (tag1, tag2), '--pretty=oneline')
+ tag_log[tag2] = log
+
+ticket_tag = dict()
+tickets = data.pop('tickets')
+for ticket in tickets:
+ for key, value in tag_log.iteritems():
+ if "[#%s]" % ticket['ticket_num'] in value:
+ ticket_tag[ticket['ticket_num']] = key
+ continue
+
+del data['milestones']
+del data['saved_bins']
+
+updated = []
+for ticket in tickets:
+ if ticket['ticket_num'] == 6054 or (ticket['status'] != 'deleted' and not ticket['private']):
+ if ticket['status'] in reviews:
+ ticket['status'] = 'review'
+
+ milestone = ticket_tag.get(ticket['ticket_num'], None)
+ if not milestone:
+ if ticket['status'] in released:
+ milestone = tags[0]
+ ticket['custom_fields']['_milestone'] = milestone or 'unreleased'
+ if '_size' in ticket['custom_fields'].keys():
+ size = ticket['custom_fields']['_size']
+ if size:
+ ticket['labels'].append("sf-%d" % int(size))
+ del ticket['custom_fields']['_size']
+
+ if '_qa' in ticket['custom_fields'].keys():
+ ticket['custom_fields']['Reviewer'] = ticket['custom_fields']['_qa']
+ del ticket['custom_fields']['_qa']
+ updated.append(ticket)
+
+data['tickets'] = updated
+data['saved_bins'] = []
+data['milestones'] = []
+with open(output, 'w') as outfile:
+ json.dump(data, outfile)