@@ -0,0 +1,1215 @@
+from jiraauth import jclient%0Aimport debugmode%0A%0A%22%22%22%0AThis script was used to copy target versions (customfield_10304)%0Ainto the fix version field.  It's a decent example of how to%0Aiterate over search results and update issues in the result set%0A%22%22%22%0A%0Ai = 0%0AmaxResults=50%0Anum = 50%0Awhile i %3C num:%0A    num, results = jclient.search_issues_with_total('%22Target Version/s%22 is not EMPTY and status not in (Resolved, Closed)', startAt=i)%0A    for issue in results:%0A        print %22checking %22 + issue.key%0A        newFixVersions = None%0A        for target_version in issue.fields.customfield_10304:%0A            if not len(%5B x for x in issue.fields.fixVersions if x.id == target_version.id %5D):%0A                if not newFixVersions:%0A                    newFixVersions = %5B x for x in issue.fields.fixVersions %5D%0A                newFixVersions.append(target_version)%0A        if newFixVersions:%0A            print %22Updating %22 + issue.key + %22 was %22 + %5C%0A                  %22,%22.join(sorted(%5Bx.name for x in issue.fields.fixVersions %5D)) + %5C%0A                  %22 now %22 + %22,%22.join(sorted(%5Bx.name for x in newFixVersions %5D))%0A            issue.update(fixVersions=%5B %7B 'name': x.name %7D for x in newFixVersions %5D)%0A    i += maxResults%0A    print i%0A     %0A

Add migrate-target-versions example