callahantiff / Abra-Collaboratory

git reproducible - version control your ideas
GNU General Public License v3.0
6 stars 5 forks source link

Script to convert wiki links relative to user's repo #5

Open tuh8888 opened 5 years ago

tuh8888 commented 5 years ago

After forking the wiki, the links still lead back to this repository.

magic-lantern commented 5 years ago

Actually I think a script replacing source username with destination username is the wrong approach to solve this problem. Despite that, here's a one-liner that will do the job. Not sure if this is the level of automation that you are looking for, but the links from callahantiff to the new username can quickly be replaced with a combination of find & sed

The solution depends on the version of find and sed you have.

For those on Linux or those that have GNU versions:

find . -type f -exec sed -i 's/callahantiff/{username}/g' {} +
git diff
# if everything looks good, then commit
git commit -a

For those on using macOS/BSD find & sed use the following. Note, while this works, it does change some line endings

find . -type f -name '*.md' -exec sed -i '' s/callahantiff/{username}/g {} +

Alternatively macOS users can use Homebrew to install the GNU version of find and sed:

brew install findutils
brew install gnu-sed
gfind . -type f -exec gsed -i 's/callahantiff/{username}/g' {} +

It would be better to actually modify the links in the repository and wiki to be relative so they don't need to be modified.

In Main repo:

In wiki:

Was there a reason for not using relative links? If there isn't a good reason to avoid relative links, I recommend updating all links to be relative (could do with find and sed) so then forkers (is that a real word?) don't have to update any URLs.

callahantiff commented 5 years ago

Thanks for your advice @tuh8888 and @magic-lantern! 👏 😺

I agree with using relative links and have successfully updated all links except the image links in the wiki, which required a small modification:

@magic-lantern can you make suggested edits to @tuh8888's script here?

magic-lantern commented 5 years ago

@callahantiff - Thanks for updating all the links. Guess I messed up on that Wiki image link pattern.

I see that New_Collaborators_Invitation_Email.md still has some full links that need updating - I'm happy to do that if you're ok with it.

I'm confused about what you mean by suggested edits to the script, please clarify. @tuh8888 has already included using GNU/Linux version of find and sed statements. After reviewing it, and including your recent changes, I have a few suggested edits to that script that I'm happy to make:

callahantiff commented 5 years ago

@magic-lantern sorry for the delay in responding. I should be able to be much more responsive going forward.

I'm confused about what you mean by suggested edits to the script, please clarify. @tuh8888 has already included using GNU/Linux version of find and sed statements.

You are right, nothing to do there.

After reviewing it, and including your recent changes, I have a few suggested edits to that script that I'm happy to make:

  • Script is only updating/replacing callahantiff in the wiki
  • The links to img.shields.io (excluding the .md file mentioned earlier) would likely be removed as people would customize their README.md for their project, so maybe don't need to worry about those.
  • The issue templates have callahantiff as the default assignee.
  • Some pages (in repo and wiki) have links to opening issues with callahantiff as the default assignee.

These changes sound great to me, I have not checked your pull request (doing that next), so if you have already made these changes, thank you very much! If not, I am fully in support of them :D.