Skip to content

Instantly share code, notes, and snippets.

@abdolrhman
Last active June 19, 2022 22:00
Show Gist options
  • Save abdolrhman/104f1b24a3e68bb7d7625ffc9887eb24 to your computer and use it in GitHub Desktop.
Save abdolrhman/104f1b24a3e68bb7d7625ffc9887eb24 to your computer and use it in GitHub Desktop.
CopyCat Problem architecture solution

Problem:

  • externalize strings of file into a seprate file
  • each time a merge is made
  • a request needs to be made Automatically
    • create a seprate PR
    • pulls all strings from the commited files
    • create random variables names for each of these strings
    • push them in a seprate predefine file
    • replace the strings on the commited files with the generated random variables that are on the predefine file

Solution:

  • when the Merge Made, there would be a service that is listenning to the merging event,
  • so when this merge happen it trigger a call to an API
  • What the API does is
    • as its being triggered from the merge event, this means that it has access to the commited files

    • with the on hand, what we need right now is to

      1. locate all strings on these files
      2. for each string found
        1. create a random variable
        2. remove the string from the file
        3. put the random variable and its respected value into the predfined file
        4. replace this removed string with the created random variable
        5. import the predefined file into the commited files that you replaced its strings,
        6. always import at the start of the file no need to do any algorthim for that
        7. the predefined file will be on the root folder of the project, so it should be simple to locate the file path based on the commited file path
    • after all strings are done,

    • a bash script that

      1. create branch, original branch + SSA which refers to strings sepration automation
      2. create another automate PR, with the original PR name + string-seprated-automated
      • something that define that this PR is automated and the job of this automation
      1. merge it or maybe some review needs to be done first, this is a choice based on the needs
    • the return of that API might be maybe an object with status check of each of these process, to make sure that it works good, or something needs to be redone,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment