rtcTo / rtc2gitcli

An IBM's RTC SCM tool extension to migrate an RTC repository into a Git repository
https://rtc.to
MIT License
28 stars 34 forks source link

Multiple enhancements and bugfixes #76

Closed pjdarton closed 1 year ago

pjdarton commented 2 years ago

Apologies for the monolithic commit. This was the result of many months of tinkering and improvement, but (with these changes) I was finally able to do the migration of hundreds of RTC streams (some of which were large) with minimal developer downtime. i.e. it's good stuff ... it's just not done in a set of nice clear-cut PRs.

Bugs fixed:

Enhancements:

Notes

pjdarton commented 2 years ago

Note: Quite happy to work with the project maintainer(s) on getting this massaged into a state where it can be merged in.

reinhapa commented 2 years ago

@pjdarton Thanks for you're work. I will try to gloss over the changes in the next days.

solzun commented 1 year ago

@pjdarton Fantastic job with this, you fixed a lot of the issues I saw back when I managed to get through this for only a few streams back in the 6.0.4. days. I'm going to clone down and pull in your PR, we're going to be testing soon with RTC 7.0.2.x and we've already noticed that the CLI breaks API compatibility in a few places. I'll let you know our status and try to get any fixes back in for support on 7.x.

pjdarton commented 1 year ago

Hi folks, While I'm glad this is seeing some interest at long last, I'm no longer involved with RTC at all; I finished migrating from RTC to GitHub in March 2022 and no longer have access to RTC at all ... for which I am thankful (as finishing the migration nearly finished me!) ... and have little appetite to revisit the experience. I'm quite happy to comment here to advise, but I'm not in a position to push this forward anymore. i.e. if you want this "in", I'd suggest you grab this branch/code/pr and make your own pr that builds upon it.

TL;DR: I'm done with RTC and, while I sympathise with those still using it, I'm just going to cheer y'all on from the sidelines rather than getting involved again myself.

solzun commented 1 year ago

@pjdarton Understood, and good job getting out of IBM's shadow, you worked a hell of a job doing it! I'm just glad you gave us so much for the rest of us in the trenches still doing this, your commits/changes will help a ton!

solzun commented 11 months ago

@pjdarton We just finished building your code on the branch from the merged PR into the branch "rtcTo:rtc6reorderedchangesets", we were able to successfully run this using ELM 7.0.2SR1 just fine with a few stream/component tests. Excellent work and great upgrades. Once we can get some time, we want to replicate/polish up your build.sh (it's way easier to run this to build the fragment jar instead of using Eclipse, we were able to build the jar in there and export it but it was a mess due to how much Eclipse hides from you.) We then were going to push up our changes to that, the pom.xml and .product file fixes for the new dependencies, and completely overhaul the README.MD for users in the future, and we'll try to get with the original maintainer of this repo to hopefully get this into master.

We only had one question from what we've been stuck on, and I wasn't sure if you had a quick answer or not, we've debugged this left and right and cannot figure it out (I appreciate anything you can provide): Your PR implemented a new class, JSONParser: https://github.com/rtcTo/rtc2gitcli/blob/rtc6reorderedchangesets/rtc2git.cli.extension/src/to/rtc/cli/migrate/util/JSONParser.java

There is an import we cannot get resolved at all: import org.eclipse.e4.core.services.util.JSONObject;

Maven no longer has this dependency, the Eclipse e4 folks, from what I see from eclipse.org bug issues, removed all JSONObject classes from these jars back in 2013: https://www.eclipse.org/lists//e4-dev/msg07224.html

When I build via Eclipse (using the Maven runner) and then export the fragment jar from Eclipse, it actually never resolves this dependency, Eclipse just force-compiles the .class file for it anyway, strips the leading import path (when I look at the decompiled output) and packages it all up. If I look at the raw .class file decompiled, Eclipse now generates it as: `package to.rtc.cli.migrate.util;

import JSONObject; import java.lang.reflect.Field; import java.util.List; import java.util.Map;`

If I dump the raw .class file: Unresolved compilation problems: The import org.eclipse.e4 cannot be resolved JSONObject cannot be resolved to a type

Somehow, some way, it's resolving this at runtime, and I have no idea how. We've trawled all the ELM SCM CLI runtime jars and dependencies trying to dig through to find where it may be working (IBM has a JSONObject class in one of its RTC SCM CLI jars), I noticed you added GSon as a dependency, but none of these imports resolves missing methods for .deserialize() and .getObjects(). I suspect maybe it's being resolved by some runtime magic of the OSGI/E4 environment that the ELM SCM CLI environment spawns when using the command-line, but I haven't used a debugger yet to check, and I still cannot build it from your build.sh as Maven rejects the compilation due to this missing dependency.

Is there any chance your build still references a very old E4 jar somewhere that contains this jar, or resolved through some other means? I wanted to ask before we went back and started searching for E4 dependencies from 10 years ago or start looking at code changes.

Peter-Darton-i2 commented 11 months ago

I suspect that I was using the Eclipse that was (part of) the official RTC client ... which was pretty old when I was using it, let alone now. I suspect that my thinking ran along the lines of "if I limit my coding to only the libraries that were already present within the official RTC client, I won't have to learn how to add new external libraries" and so I went searching for JSON-parsing capabilities within the Eclipse classpath... I'd guess that RTC now has a much newer Eclipse at its heart which has very different libraries inside it, which is why that import isn't available anymore.

I'd suggest you try a different tactic - rather than try to get that code working "as-is" by replacing the import that it wants, I suspect you'll find it easier to "just" re-implement the code to use something else.

i.e. Take a look at where this JSONParser object is used from (which is ListChangesCommandOutputParser and ListMissingChangeSetsCommandOutputParser) and then see what JSON-parsing code you can find on your classpath that can do the same job. I expect that Eclipse still contains some JSON-parsing libraries, even if it doesn't contain that one anymore.

FYI the actual functionality these two calling classes need is relatively simple. They're given a string (which contains the text output from running an RTC command), parsing it as JSON, and then they're extracting particular bits of that data. e.g. ListMissingChangeSetsCommandOutputParser just wants to collect all of changes[].uuid from the JSON. ListChangesCommandOutputParser goes into much more detail than that but it's still "just" parsing a bit of JSON to extract meaning from it and populate a simpler Java construct.

So, instead of looking for org.eclipse.e4.core.services.util.JSONObject, go looking for a more modern JSON parser and change the code to use that instead. You may even find a JSON parser that can be used directly by the two ...CommandOutputParser classes without requiring an adaptor class to fix its shortcomings (as 90% of JSONParser is workarounds).

FYI There's even a unit test for both those classes, so if you can find something that "seems to work" then you can run those to be fairly sure it'll work "for real".