I had decided to bike a longer route than I usually do and ended up getting caught in the rain and biked back to my car with some extreme leg cramps. It was extremely painful, but I didn't want to get caught past dark in the rain and the trip back was a little less than 2 hours. I had barely made it back before my legs completely locked up, but the cramps gradually let up and I was able to walk normally again with just some minor muscle soreness. I understand that the situation that I put myself in was preventable, but I was curious if there is any permanent damage done when pushing through cramps when exercising.
I highly doubt it. In general, cramps are caused by electrolyte imbalances and make your muscles contract uncontrollably for a period of time. The long term damage would be no more than what would happen if you contracted your muscles for the same amount of time. Now, you will need to fix the electrolyte imbalances with proper rest and hydration.
According to the article that I linked to, the only time you should be concerned is if you chronically get the cramping in the same set of muscles without causing the cramp by your exercise. It's an indication of nerve root disease. However, that doesn't apply to the situation you described here.
The best prevention for cramps is a good hydration routine. When you are doing long distance biking or running, you should probably keep some Gatorade or other sports drink on you so you can remain hydrated throughout your ride. The sports drinks help maintain the proper electrolyte imbalances so you don't experience the severe pain that you did.
There is almost no direct evidence that muscle cramps are caused by electrolyte or water imbalances (given normal hydration prior to start). https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3445088/ Its most likely due to the muscle being "pre-tight" and stretching is the best prevention and therapy. No one knows actually the cause of cramps.
I'm going to provide a slightly different answer on this:
if there is any permanent damage done when pushing through cramps when exercising?
Potentially. Similar to DOMS, a lot of the focus on training through the discomfort assumes that you can hold perfect form. If you are squatting, as an example, and develop pain your left leg, there is a very good chance you will reflexively transfer weight to your right side. While this is a natural and terrific way for our bodies to adapt in real-time to injuries, it's a big issue if you're trying to hold good form during exercises that have a big price tag for bad form.
With DOMS, cramps, and even just being really tired, I would caution folks to ensure they are holding a proper form. Not favoring one side or another, and not trying to work around the pain by shifting the load a bit.