Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check repo name before shortening links #300

Open
sonniki opened this issue Feb 19, 2025 · 0 comments
Open

Check repo name before shortening links #300

sonniki opened this issue Feb 19, 2025 · 0 comments
Labels
good first issue Good for newcomers

Comments

@sonniki
Copy link
Contributor

sonniki commented Feb 19, 2025

In linters/amp_fix_md_links.py, we have the following section handling http links:

    if link.startswith("http"):
        if not any(
            x in link
            for x in ["://github.com/cryptokaizen", "://github.com/causify-ai"]
        ):
            # The link is to an external resource; update is not needed.
            return line, warnings
        if "blob/master" not in link:
            # The link is not to a file (but, for example, to an issue);
            # update is not needed.
            return line, warnings
        # Leave only the path to the file in the link.
        link = link.split("blob/master")[-1]

What it does is it turns, for example, https://github.com/causify-ai/helpers/blob/master/linters/amp_fix_md_links.py into /linters/amp_fix_md_links.py. However, there is a problem if the link is supposed to point to a file in another repo. For example, if a file in cmamp has this link, then after cutting off the first part, the link will be actually broken because there is no /linters/amp_fix_md_links.py in cmamp.

We need to update the logic and only cut off the first part of the link if the repo name it contains is the same as the local repo (the one where the file that is being linted is located).

@sonniki sonniki self-assigned this Feb 19, 2025
@sonniki sonniki added the good first issue Good for newcomers label Feb 26, 2025
@sonniki sonniki removed their assignment Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant