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

core/muxer: Remove deprecated functions #3031

Merged
merged 4 commits into from
Nov 2, 2022

Conversation

thomaseizinger
Copy link
Contributor

Description

I haven't done the version bumps yet because it is so damn painful.

Links to any relevant issues

Open Questions

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • A changelog entry has been made in the appropriate crates

Copy link
Member

@mxinden mxinden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing the version bumps. Otherwise looks good to me. Thanks for the follow up.

@mxinden
Copy link
Member

mxinden commented Oct 31, 2022

Friendly ping @thomaseizinger. I can also do it with my Python script. Shouldn't take me too long. Let me know.

@thomaseizinger
Copy link
Contributor Author

Friendly ping @thomaseizinger. I can also do it with my Python script. Shouldn't take me too long. Let me know.

Completely forgot about this. Can you send me your script again please? I tried to find it the other day but couldn't.

@mxinden
Copy link
Member

mxinden commented Nov 2, 2022

With recent merges, libp2p-core is already updated.

For the future, hacky python script:

#!/usr/bin/env python3

from pathlib import Path
from tomlkit import loads
from tomlkit import dumps
from itertools import tee
import semver
import sys

rootdir = Path('./')

indent = ""

def update_dependents(dependency_name, level):

    file_list_1, file_list_2 = tee(filter(lambda f: not "target" in str(f), [f for f in rootdir.glob('**/Cargo.toml') if f.is_file()]))

    dependency_version = ""
    dependency_changelog_path = ""
    for f in file_list_1:
        cargo_toml = loads(f.read_text())
        if cargo_toml["package"]["name"] == dependency_name:
            dependency_version = cargo_toml["package"]["version"]
            dependency_changelog_path = Path(f.parents[0]).joinpath("CHANGELOG.md")
            break

    print(level + "Updating all dependents of " + dependency_name + " to " + dependency_name + " " + dependency_version + ".")

    level = level + " "

    for cargo_toml_file in file_list_2:
        cargo_toml = loads(cargo_toml_file.read_text())
        dependent_name = cargo_toml["package"]["name"]
        print(level, "Checking: " + dependent_name)
        if dependent_name != dependency_name:
            if "dependencies" in cargo_toml:

                if dependency_name in cargo_toml["dependencies"] and cargo_toml["dependencies"][dependency_name]["version"] != dependency_version:
                    cargo_toml["dependencies"][dependency_name]["version"] = dependency_version
                    cargo_toml_file.write_text(dumps(cargo_toml))

                    changelog_file = Path(cargo_toml_file.parents[0]).joinpath("CHANGELOG.md")
                    if changelog_file.exists():
                        text = list(open(changelog_file))
                        dependent_version = semver.VersionInfo.parse(cargo_toml["package"]["version"])

                        # Update dependent version based on changelog header.
                        if "[unreleased]" in text[0]:
                            if dependent_version.major == 0 and dependent_version.patch == 0:
                                # Nothing to be done, already bumped.
                                pass
                            elif dependent_version.major == 0 and dependent_version.patch != 0:
                                dependent_version = dependent_version.bump_minor().replace(patch=0)
                                text.pop(0)
                                text.insert(0, "# " + str(dependent_version) + " [unreleased]\n")
                                text.insert(1, "\n")
                            elif dependent_version.minor != 0 or dependent_version.patch != 0:
                                dependent_version = dependent_version.bump_major().replace(patch=0, minor=0)
                                text.pop(0)
                                text.insert(0, "# " + str(dependent_version) + " [unreleased]\n")
                                text.insert(1, "\n")
                            else:
                                # Nothing to be done, already bumped.
                                pass
                        elif "# " in text[0]:
                            # Bump version of dependent
                            if dependent_version.major == 0:
                                dependent_version = dependent_version.bump_minor().replace(patch=0)
                            else:
                                dependent_version = dependent_version.bump_major().replace(patch=0, minor=0)

                            text.insert(0, "# " + str(dependent_version) + " [unreleased]\n")
                            text.insert(1, "\n")
                        else:
                            pass

                        if dependent_name == "libp2p":
                            text.insert(2, "- Update to [`" + dependency_name + "` `v" + dependency_version + "`](" + str(dependency_changelog_path) + "#" + dependency_version.replace(".", "") + ").\n")
                        else:
                            text.insert(2, "- Update to `" + dependency_name + "` `v" + dependency_version + "`.\n")

                        text.insert(3, "\n")

                        changelog_file.write_text("".join(text))

                        cargo_toml["package"]["version"] = str(dependent_version)
                        cargo_toml_file.write_text(dumps(cargo_toml))

                        update_dependents(dependent_name, level + " ")



def main():
    update_dependents(sys.argv[1], "")


if __name__ == '__main__':
    main()

@mxinden mxinden merged commit df659e5 into master Nov 2, 2022
@thomaseizinger thomaseizinger deleted the remove-deprecated-muxer-functions branch November 17, 2022 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants