A code migration method and device, electronic equipment and storage medium
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA CONSTRUCTION BANK
- Filing Date
- 2022-09-22
- Publication Date
- 2026-08-07
AI Technical Summary
然而,CC难以支持代码的敏捷开发,随着银行等企业的业务和市场的发展,需要企业快速响应市场,代码需要被敏捷开发,适合敏捷开发代码的配置管理工具Gitee等应运而生,为了可以支持代码的敏捷开发,就需要将代码的配置管理工具由CC切换为Gitee等
[0043]由于本申请可以针对旧配置管理工具中需要进行代码迁移的设定数量个原目标分支,基于预先保存的原分支与新分支的对应关系,分别确定在新配置管理工具中,各原目标分支各自对应的新目标分支;并针对每个原目标分支,从旧配置管理工具对应的旧代码库中,获取该原目标分支对应的目标代码;将该目标代码确定为相应的新目标分支对应的代码,并将目标代码保存到新配置管理工具对应的新代码库中,基于此,可以实现在对代码的配置管理工具进行切换时,可以平稳安全准确地对代码进行迁移的目的。
Smart Images

Figure CN115495150B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to a code migration method, apparatus, electronic device, and storage medium. Background Technology
[0002] Switching to a different configuration management tool is inevitable. For example, ClearCase (CC) can be used as a configuration management tool in related technologies. CC's centralized and exclusive nature minimizes code conflicts and merging issues caused by multiple people modifying the same code file simultaneously, ensuring system security and stability. However, CC struggles to support agile code development. As businesses and markets evolve, banks and other enterprises require rapid market response, necessitating agile code development. Configuration management tools suitable for agile code development, such as Gitee, have emerged. To support agile code development, the configuration management tool needs to be switched from CC to Gitee or a similar tool.
[0003] However, when switching configuration management tools for code, how to smoothly and accurately migrate the code is a technical problem that urgently needs to be solved. Summary of the Invention
[0004] This application provides a code migration method, apparatus, electronic device, and storage medium for smoothly and accurately migrating code.
[0005] Firstly, this application provides a code migration method, the method comprising:
[0006] For the set number of original target branches that need to be migrated in the old configuration management tool, based on the pre-saved correspondence between the original branches and the new branches, the corresponding new target branches for each original target branch in the new configuration management tool are determined.
[0007] For each original target branch, obtain the target code corresponding to that original target branch from the old code repository corresponding to the old configuration management tool; determine the target code as the code corresponding to the new target branch, and save the target code to the new code repository corresponding to the new configuration management tool.
[0008] In one possible implementation, before retrieving the target code corresponding to each original target branch from the old code repository corresponding to the old configuration management tool, the method further includes:
[0009] For each original target branch, if the target code corresponding to that original target branch has been developed and put into production, then proceed with the subsequent steps.
[0010] In one possible implementation, the method further includes:
[0011] For each original target branch, based on the new pipeline corresponding to the new configuration management tool, the code of the new target branch corresponding to the original target branch is run to generate a first version package artifact; and based on the old pipeline corresponding to the old configuration management tool, the target code in the original target branch is run to generate a second version package artifact; the first version package artifact and the second version package artifact are compared to generate a first comparison result, and based on the first comparison result, the code execution results are verified to be the same.
[0012] In one possible implementation, the method further includes:
[0013] For each original target branch, download the target code corresponding to that original target branch from the old code repository, and download the code of the new target branch corresponding to that original target branch from the new code repository; compare the downloaded target code corresponding to the original target branch with the code corresponding to the corresponding new target branch to generate a second comparison result; based on the second comparison result, verify whether the target code corresponding to the original target branch and the code corresponding to the corresponding new target branch are the same.
[0014] In one possible implementation, the method further includes determining the corresponding new target branch in the new configuration management tool before each of the predetermined number of original target branches requiring code migration in the old configuration management tool, based on a pre-saved correspondence between original and new branches:
[0015] Copy the base code specified in the old codebase to the new codebase;
[0016] Download the baseline code from the old codebase and the baseline code from the new codebase; compare the downloaded baseline code from the old codebase with the downloaded baseline code from the new codebase to generate a third comparison result; based on the third comparison result, verify whether the baseline code in the old and new codebases is the same; if the verification passes, proceed to the next steps.
[0017] In one possible implementation, the method further includes determining the corresponding new target branch in the new configuration management tool before each of the predetermined number of original target branches requiring code migration in the old configuration management tool, based on a pre-saved correspondence between original and new branches:
[0018] Copy the base code specified in the old codebase to the new codebase;
[0019] Based on the new pipeline corresponding to the new configuration management tool, the base code is obtained from the new code repository;
[0020] The baseline code obtained by the new pipeline is compared with the baseline code stored in the new code library to generate a fourth comparison result. Based on the fourth comparison result, the correctness of the code obtained by the new pipeline is verified. If the verification is successful, the subsequent steps are performed.
[0021] In one possible implementation, the method further includes determining the corresponding new target branch in the new configuration management tool before each of the predetermined number of original target branches requiring code migration in the old configuration management tool, based on a pre-saved correspondence between original and new branches:
[0022] Copy the base code specified in the old codebase to the new codebase;
[0023] Based on the old pipeline corresponding to the old configuration management tool, the baseline code is obtained from the old code repository; and based on the new pipeline corresponding to the new configuration management tool, the baseline code is obtained from the new code repository.
[0024] The baseline code obtained from the old pipeline is compared with the baseline code obtained from the new pipeline to generate a corresponding fifth comparison result. Based on the fifth comparison result, the consistency of the code obtained from the old and new pipelines is verified. If the verification is successful, the subsequent steps are performed.
[0025] In one possible implementation, the method further includes determining the corresponding new target branch in the new configuration management tool before each of the predetermined number of original target branches requiring code migration in the old configuration management tool, based on a pre-saved correspondence between original and new branches:
[0026] Copy the base code specified in the old codebase to the new codebase;
[0027] The baseline code is run on the new pipeline corresponding to the new configuration management tool to generate the third version package artifact, and the baseline code is run on the old pipeline corresponding to the old configuration management tool to generate the fourth version package artifact.
[0028] The third version package artifact is compared with the fourth version package artifact to generate a sixth comparison result. Based on the sixth comparison result, the code execution results are verified to be the same. If the verification is successful, the subsequent steps are performed.
[0029] Secondly, this application provides a code migration apparatus, the apparatus comprising:
[0030] The determination module is used to determine the new target branch corresponding to each original target branch in the new configuration management tool based on a pre-saved correspondence between the original branches and the new branches, for a set number of original target branches in the old configuration management tool that need to be migrated.
[0031] The migration module is used to obtain the target code corresponding to each original target branch from the old code repository corresponding to the old configuration management tool; determine the target code as the code corresponding to the new target branch; and save the target code to the new code repository corresponding to the new configuration management tool.
[0032] In one possible implementation, the determining module is further configured to, for each original target branch, if it is identified that the target code corresponding to the original target branch has been developed and put into production, then perform the step of obtaining the target code corresponding to the original target branch from the old code library corresponding to the old configuration management tool for each original target branch.
[0033] In one possible implementation, the device further includes:
[0034] The verification module is used to, for each original target branch, run the code of the new target branch corresponding to the new pipeline of the new configuration management tool to generate a first version package artifact; and run the target code in the original target branch based on the old pipeline of the old configuration management tool to generate a second version package artifact; compare the first version package artifact with the second version package artifact to generate a first comparison result; and verify whether the code execution results are the same based on the first comparison result.
[0035] In one possible implementation, the verification module is further configured to: download the target code corresponding to the original target branch in the old code repository for each original target branch; download the code of the new target branch corresponding to the original target branch in the new code repository; compare the downloaded target code corresponding to the original target branch with the code corresponding to the corresponding new target branch to generate a second comparison result; and verify whether the target code corresponding to the original target branch and the code corresponding to the corresponding new target branch are the same based on the second comparison result.
[0036] In one possible implementation, the determining module is further configured to copy the base code specified in the old code repository to the new code repository; download the base code in the old code repository and download the base code in the new code repository; compare the downloaded base code in the old code repository with the downloaded base code in the new code repository to generate a third comparison result; verify whether the base code in the old and new code repositories is the same based on the third comparison result; if the verification is successful, proceed to the following steps: for a set number of original target branches that need to be migrated in the old configuration management tool, determine the new target branch corresponding to each original target branch in the new configuration management tool based on the pre-saved correspondence between the original branches and the new branches.
[0037] In one possible implementation, the determining module is further configured to: copy the baseline code specified in the old codebase to the new codebase; obtain the baseline code from the new codebase based on the new pipeline corresponding to the new configuration management tool; compare the baseline code obtained by the new pipeline with the baseline code stored in the new codebase to generate a fourth comparison result; verify whether the code obtained by the new pipeline is correct based on the fourth comparison result; and if the verification is successful, proceed to the following steps: for a set number of original target branches in the old configuration management tool that need code migration, determine the new target branch corresponding to each original target branch in the new configuration management tool based on the pre-saved correspondence between the original branches and the new branches.
[0038] In one possible implementation, the determining module is further configured to copy the base code specified in the old code repository to the new code repository; obtain the base code from the old code repository based on the old pipeline corresponding to the old configuration management tool; and obtain the base code from the new code repository based on the new pipeline corresponding to the new configuration management tool; compare the base code obtained from the old pipeline with the base code obtained from the new pipeline to generate a corresponding fifth comparison result; verify whether the code obtained from the old and new pipelines is consistent based on the fifth comparison result; if the verification is successful, proceed to the following steps: for a set number of original target branches in the old configuration management tool that need code migration, determine the new target branch corresponding to each original target branch in the new configuration management tool based on the pre-saved correspondence between the original branches and the new branches.
[0039] In one possible implementation, the determining module is further configured to: copy the baseline code specified in the old codebase to the new codebase; run the baseline code based on the new pipeline corresponding to the new configuration management tool to generate a third version package artifact, and run the baseline code based on the old pipeline corresponding to the old configuration management tool to generate a fourth version package artifact; compare the third version package artifact with the fourth version package artifact to generate a sixth comparison result; verify whether the code execution results are the same based on the sixth comparison result; if the verification is successful, proceed to the following steps: for a set number of original target branches in the old configuration management tool that need code migration, determine the new target branch corresponding to each original target branch in the new configuration management tool based on the pre-saved correspondence between the original branches and the new branches.
[0040] Thirdly, this application provides an electronic device that includes at least a processor and a memory, wherein the processor is configured to execute a computer program stored in the memory to implement the steps of any of the methods described above.
[0041] Fourthly, this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of any of the methods described above.
[0042] Fifthly, this application provides a computer program product comprising: computer program code, which, when run on a computer, causes the computer to perform the steps of any of the methods described above.
[0043] This application can determine the corresponding new target branch in the new configuration management tool for each of the set number of original target branches that need to be migrated in the old configuration management tool, based on the pre-saved correspondence between the original branches and the new branches. For each original target branch, the application retrieves the target code corresponding to that original target branch from the old code repository corresponding to the old configuration management tool. This target code is then identified as the code corresponding to the new target branch and saved to the new code repository corresponding to the new configuration management tool. Based on this, the application can achieve the goal of smoothly, safely, and accurately migrating the code when switching configuration management tools. Attached Figure Description
[0044] To more clearly illustrate the implementation methods in the embodiments of this application or related technologies, the accompanying drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings.
[0045] Figure 1 A schematic diagram of a first code migration process provided by some embodiments is shown;
[0046] Figure 2 A schematic diagram of a second code migration process provided by some embodiments is shown;
[0047] Figure 3 A schematic diagram of a third code migration process provided by some embodiments is shown;
[0048] Figure 4 A schematic diagram of a fourth code migration process provided in some embodiments is shown;
[0049] Figure 5 A schematic diagram of a fifth code migration process provided in some embodiments is shown;
[0050] Figure 6 A schematic diagram of a code migration apparatus provided in some embodiments is shown;
[0051] Figure 7 A schematic diagram of an electronic device structure provided by some embodiments is shown. Detailed Implementation
[0052] To make the objectives, technical solutions, and advantages of this application clearer, a further detailed description of this application will be provided below with reference to the accompanying drawings. Obviously, the embodiments described in this application are merely some embodiments, not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0053] It should be noted that the brief descriptions of terms in this application are only for the convenience of understanding the embodiments described below, and are not intended to limit the embodiments of this application. Unless otherwise stated, these terms should be understood in their ordinary and common meaning.
[0054] The terms "first," "second," "third," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar or related objects or entities, and do not necessarily imply a specific order or sequence, unless otherwise specified. It should be understood that such terms are interchangeable where appropriate.
[0055] The terms “comprising” and “having”, and any variations thereof, are intended to cover but not exclude inclusion, for example, a product or device that includes a range of components is not necessarily limited to all of the components that are clearly listed, but may include other components that are not clearly listed or that are inherent to such product or device.
[0056] The term "module" refers to any known or subsequently developed hardware, software, firmware, artificial intelligence, fuzzy logic, or combination of hardware and / or software code that is capable of performing the functions associated with that element.
[0057] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
[0058] In order to ensure a smooth and accurate migration of code when switching configuration management tools, this application provides a code migration method, apparatus, electronic device, and storage medium.
[0059] Example 1:
[0060] All embodiments of this application comply with the relevant provisions of national laws and regulations regarding the acquisition, storage, use, and processing of data.
[0061] Figure 1 The diagram illustrates a first-type code migration process provided by some embodiments, such as... Figure 1 As shown, the process includes the following steps:
[0062] S101: For a set number of original target branches in the old configuration management tool that require code migration, based on the pre-saved correspondence between the original branches and the new branches, determine the corresponding new target branch for each original target branch in the new configuration management tool.
[0063] The code migration method provided in this application is applied to electronic devices, such as PCs, mobile terminals, or servers.
[0064] In one possible implementation, taking ClearCase (CC) as an example, the code developed based on CC includes not only code that has been completed and deployed in the production environment, but also a large amount of parallel development code still under development. If this large amount of parallel development code is directly migrated from the old codebase of the old configuration management tool to the new codebase of the new configuration management tool according to a set switchover time, a large number of code conflicts may occur. If conflict handling is not handled carefully, incorrect code may overwrite correct code, potentially causing production problems and other accidents. In one possible implementation, to ensure a smooth, safe, and accurate code migration when switching configuration management tools, this application embodiment, for a set number of original target branches in the old configuration management tool that need code migration, can determine the corresponding new target branch in the new configuration management tool based on a pre-saved correspondence between original and new branches. This application does not impose a specific limit on the number of original target branches used in each code migration, which can be flexibly set according to needs. Optionally, to improve the stability, security, and accuracy of the code migration process, the number of original target branches used in each migration can be a small number such as 1 or 2. Taking a setting of 1 original target branch for each migration as an example, it means that only the code of one original target branch is migrated at a time.
[0065] In one possible implementation, in order to improve the smoothness, security and accuracy of the code migration process, the correspondence between the original branch of the old configuration management tool and the new branch of the new configuration management tool can be saved in advance. The correspondence between the original branch and the new branch can be flexibly set according to the needs, and this application does not make specific limitations on it.
[0066] S102: For each original target branch, obtain the target code corresponding to the original target branch from the old code repository corresponding to the old configuration management tool; determine the target code as the code corresponding to the new target branch, and save the target code to the new code repository corresponding to the new configuration management tool.
[0067] In one possible implementation, to ensure a smooth, safe, and accurate code migration when switching configuration management tools, for parallel development code already in the development and testing phase, the old configuration management tool can still be used. The corresponding code can be developed in the old codebase of the old configuration management tool. For each original target branch, code migration can be performed only after the code for that original target branch has been developed and deployed. In another possible implementation, once the code for the original target branch has been developed and deployed, developers can identify that the configuration code for that original target branch has been developed and deployed. Based on this identifier, the electronic device can recognize that the target code corresponding to that original target branch has been developed and deployed. For that original target branch, the code can be retrieved from the old codebase of the old configuration management tool, identified as the code for the corresponding new target branch, and saved to the new codebase of the new configuration management tool.
[0068] For ease of understanding, the code migration process provided in this application will be described below through a specific embodiment. Figure 2 The diagram illustrates a second code migration process provided by some embodiments, such as... Figure 2 As shown, the process includes the following steps:
[0069] S201: For a specific original target branch in the old configuration management tool that requires code migration, based on the pre-saved correspondence between the original branch and the new branch, determine the corresponding new target branch in the new configuration management tool.
[0070] S202: If it is identified that the target code corresponding to the original target branch has been developed and put into production, then obtain the target code corresponding to the original target branch from the old code repository corresponding to the old configuration management tool; identify the target code as the code corresponding to the new target branch, and save the target code to the new code repository corresponding to the new configuration management tool.
[0071] In one possible implementation, when switching the configuration management tool for the code, for new requirements for which no code development has yet been carried out, the code applicable to the new requirements can be developed directly based on the new configuration management tool and the new code repository corresponding to the new configuration management tool, using the current production code.
[0072] This application can determine the corresponding new target branch in the new configuration management tool for each of the set number of original target branches that need to be migrated in the old configuration management tool, based on the pre-saved correspondence between the original branches and the new branches. For each original target branch, the application retrieves the target code corresponding to that original target branch from the old code repository corresponding to the old configuration management tool. This target code is then identified as the code corresponding to the new target branch and saved to the new code repository corresponding to the new configuration management tool. Based on this, the application can achieve the goal of smoothly, safely, and accurately migrating the code when switching configuration management tools.
[0073] Example 2:
[0074] All embodiments of this application comply with the relevant provisions of national laws and regulations regarding the acquisition, storage, use, and processing of data.
[0075] In one possible implementation, the target code corresponding to the original target branch is identified as the code corresponding to the new target branch. That is, after code migration, it is necessary to verify whether the target code corresponding to the original target branch is the same as the corresponding code in the new target branch, to ensure consistency and accuracy of the code migration. In one possible implementation, the process of verifying the similarity between the target code corresponding to the original target branch and the corresponding code in the new target branch can be as follows:
[0076] For each original target branch, download the corresponding target code from the old codebase. Simultaneously, download the corresponding new target branch code from the new codebase. Then, compare the downloaded target code from the original target branch with the corresponding new target branch code to generate a second comparison result (for simplicity, this comparison result is referred to as the second comparison result). Optionally, a file comparison tool (BCompare) can be used to compare the target code from the original target branch with the corresponding new target branch code to generate a second comparison result. This second comparison result may include a list of files where the target code from the original target branch differs from the corresponding new target branch code, along with the specific differences. Based on this second comparison result, the identity of the target code from the original target branch and the corresponding new target branch code can be verified.
[0077] In one possible implementation, when the second comparison result shows that the target code corresponding to the original target branch is the same as the code corresponding to the corresponding new target branch, a verification pass message indicating code similarity can be output. When the second comparison result shows that the target code corresponding to the original target branch is different from the code corresponding to the corresponding new target branch, the second comparison result may include a list of files where the target code corresponding to the original target branch differs from the code corresponding to the corresponding new target branch, as well as the specific differences, and output a pre-defined verification fail message indicating code difference, reminding developers to find the cause of the difference and to repeat the above verification process of whether the target code corresponding to the original target branch is the same as the code corresponding to the corresponding new target branch, until the target code corresponding to the original target branch is the same as the code corresponding to the corresponding new target branch.
[0078] For ease of understanding, the code migration process provided in this application will be described below through a specific embodiment. Figure 3 The diagram illustrates a third code migration process provided by some embodiments, such as... Figure 3 As shown, the process includes the following steps:
[0079] S301: For a specific original target branch in the old configuration management tool that requires code migration, based on the pre-saved correspondence between the original branch and the new branch, determine the corresponding new target branch in the new configuration management tool.
[0080] S302: If it is identified that the target code corresponding to the original target branch has been developed and put into production, then obtain the target code corresponding to the original target branch from the old code repository corresponding to the old configuration management tool; identify the target code as the code corresponding to the new target branch, and save the target code to the new code repository corresponding to the new configuration management tool.
[0081] S303: Download the target code corresponding to the original target branch in the old code repository, and download the code of the new target branch corresponding to the original target branch in the new code repository; compare the downloaded target code corresponding to the original target branch with the code corresponding to the new target branch to generate a second comparison result; based on the second comparison result, verify whether the target code corresponding to the original target branch and the code corresponding to the new target branch are the same.
[0082] Since this application can verify whether the target code corresponding to the original target branch is the same as the code corresponding to the new target branch, it can improve the accuracy of code migration.
[0083] Example 3:
[0084] All embodiments of this application comply with the relevant provisions of national laws and regulations regarding the acquisition, storage, use, and processing of data.
[0085] In one possible implementation, the target code corresponding to the original target branch is identified as the code corresponding to the new target branch. That is, after code migration, it is necessary to verify whether the execution result of the code generated based on the target code corresponding to the original target branch (i.e., the version package artifact; for ease of description, the version package artifact generated based on the target code corresponding to the original target branch is referred to as the second version package artifact) is the same as the version package artifact generated based on the code corresponding to the new target branch (for ease of description, the version package artifact generated based on the code corresponding to the new target branch is referred to as the first version package artifact). This ensures the consistency between the first and second version package artifacts and guarantees the accuracy of the code migration. In one possible implementation, the verification process for whether the code execution result (the first version package artifact and the second version package artifact) is the same can be as follows:
[0086] For each original target branch, the code of the corresponding new target branch (the new target branch corresponding to the original target branch) is run based on the new pipeline corresponding to the new configuration management tool, thereby generating the first version package artifact. Simultaneously, the target code in the original target branch can also be run based on the old pipeline corresponding to the old configuration management tool, thereby generating the second version package artifact. The first version package artifact and the second version package artifact are compared using tools such as BCompare to generate a first comparison result (for ease of description, the comparison result between the first and second version package artifacts is referred to as the first comparison result). Based on the first comparison result, it can be verified whether the code execution results of the target code corresponding to the original target branch and the code corresponding to the corresponding new target branch are the same.
[0087] In one possible implementation, when the first comparison result shows that the first version package artifact and the second version package artifact are the same, a verification pass message can be output indicating that the code execution results are the same or that the first version package artifact and the second version package artifact are the same. When the first comparison result shows that the first version package artifact and the second version package artifact are different, the first comparison result can include information about the difference between the first version package artifact and the second version package artifact, and a verification fail message indicating that the code execution results are different can be output to remind developers to find the cause of the difference. The code migration of the original target branch can be performed again until the code execution results (first version package artifact and second version package artifact) of the target code corresponding to the original target branch and the code corresponding to the new target branch are the same.
[0088] Since this application can verify whether the execution results of the target code corresponding to the original target branch and the code corresponding to the new target branch are the same, it can improve the accuracy of code migration.
[0089] For ease of understanding, the code migration process provided in this application will be described below through a specific embodiment. Figure 4 The diagram illustrates a fourth code migration process provided in some embodiments, such as... Figure 4 As shown, the process includes the following steps:
[0090] S401: For a specific original target branch in the old configuration management tool that requires code migration, based on the pre-saved correspondence between the original branch and the new branch, determine the corresponding new target branch in the new configuration management tool.
[0091] S402: If it is identified that the target code corresponding to the original target branch has been developed and put into production, then obtain the target code corresponding to the original target branch from the old code repository corresponding to the old configuration management tool; identify the target code as the code corresponding to the new target branch, and save the target code to the new code repository corresponding to the new configuration management tool.
[0092] S403: Based on the new pipeline corresponding to the new configuration management tool, run the code of the new target branch corresponding to the original target branch to generate the first version package artifact; and based on the old pipeline corresponding to the old configuration management tool, run the target code in the original target branch to generate the second version package artifact; compare the first version package artifact with the second version package artifact to generate the first comparison result, and verify whether the code execution results are the same based on the first comparison result.
[0093] S404: Download the target code corresponding to the original target branch in the old code repository, and download the code of the new target branch corresponding to the original target branch in the new code repository; compare the downloaded target code corresponding to the original target branch with the code corresponding to the new target branch to generate a second comparison result; based on the second comparison result, verify whether the target code corresponding to the original target branch and the code corresponding to the new target branch are the same.
[0094] The above embodiments are merely illustrative examples. This application does not impose a specific limitation on the order of S403 and S404. For example, the step of verifying whether the code execution results of the target code corresponding to the original target branch and the code corresponding to the new target branch are the same can be performed first in S403. Alternatively, the step of verifying whether the target code corresponding to the original target branch and the code corresponding to the new target branch are the same can be performed first in S404. S403 and S404 can also be performed simultaneously.
[0095] Example 4:
[0096] All embodiments of this application comply with the relevant provisions of national laws and regulations regarding the acquisition, storage, use, and processing of data.
[0097] During code migration, it's crucial to ensure that the code itself remains unchanged or unmodified after being migrated from the old codebase of the old configuration management tool to the new codebase of the new configuration management tool. In one possible implementation, to guarantee a smooth and accurate migration, before migrating the target code, it's possible to verify that the base code in the new codebase is identical to the base code in the old codebase. If they are identical, the verification passes, and the migration can proceed. If they are different, the verification fails. Developers can then investigate the cause of the discrepancy and repeat the verification process until it succeeds.
[0098] In one possible implementation, the process of verifying whether the code migrated to the new codebase (base code) is the same as the code in the old codebase (base code) can be as follows:
[0099] The baseline code specified in the old codebase is copied to the new codebase; the baseline code in both the old and new codebases is downloaded; using tools such as BCompare, the downloaded baseline code in the old codebase is compared with the downloaded baseline code in the new codebase, generating a third comparison result. Based on this third comparison result, the identity of the baseline code migrated to the new codebase and the baseline code in the old codebase (referred to as the baseline code in the old and new codebases for convenience) is verified. Optionally, if the third comparison result indicates that the baseline code in the old and new codebases is identical, a verification pass message can be output, and subsequent code migration work for the target code can be considered. If the third comparison result shows that the baseline code in the new and old codebases is different, the third comparison result may include a list of differences between the baseline code in the new codebase and the baseline code in the old codebase, and may output a verification failure message indicating that the baseline code in the new and old codebases is different, reminding developers to find the reason for the difference and to repeat the above verification process of whether the baseline code migrated to the new codebase is the same as the baseline code in the old codebase until the verification passes.
[0100] In one possible implementation, to ensure the smoothness and accuracy of code migration, before migrating the code, it can be verified whether the new pipeline can accurately pull the correct and complete code (code retrieval). Optionally, the verification process for whether the new pipeline can accurately retrieve the code can be performed based on benchmark code specified by the developers. The verification process for whether the new pipeline can accurately retrieve the code can be as follows:
[0101] The baseline code specified in the old code repository corresponding to the old configuration management tool is copied to the new code repository corresponding to the new configuration management tool. Based on the new pipeline corresponding to the new configuration management tool, the baseline code is obtained from the new code repository. The baseline code obtained by the new pipeline can be compared with the baseline code stored in the new code repository using tools such as BCompare to generate a fourth comparison result. Based on the fourth comparison result, the correctness of the code obtained by the new pipeline is verified.
[0102] In one possible implementation, when the fourth comparison result shows that the baseline code acquired by the new pipeline is the same as the baseline code stored in the new code library, a verification pass message indicating that the new pipeline has correctly acquired the code can be output. When the fourth comparison result shows that the baseline code acquired by the new pipeline is different from the baseline code stored in the new code library, the fourth comparison result may include a list of differences between the baseline code acquired by the new pipeline and the baseline code stored in the new code library, and output a verification failure message indicating that the new pipeline has incorrectly acquired the code, reminding developers to find the cause of the difference, and allowing them to repeat the above verification process to check whether the new pipeline can accurately (correctly) acquire the code until the verification passes.
[0103] In one possible implementation, in addition to verifying whether the code migrated to the new codebase (base code) is the same as the code in the old codebase (base code), and verifying whether the code obtained by the new pipeline is correct, it is also possible to verify whether the code obtained by the new pipeline is consistent with the code obtained by the old pipeline (for ease of description, referred to as the code obtained by the new and old pipelines). This ensures that the code obtained by the new and old pipelines is the same for the same code, thereby ensuring that the code execution results of the new pipeline and the old pipeline are consistent after code migration.
[0104] Optionally, a verification process can be performed based on the baseline code specified by the developer to check whether the code obtained from the new and old pipelines is consistent. This verification process can be as follows:
[0105] The baseline code specified by developers in the old codebase is copied to the new codebase. Based on the old pipeline corresponding to the old configuration management tool, baseline code is obtained from the old codebase; simultaneously, based on the new pipeline corresponding to the new configuration management tool, baseline code is obtained from the new codebase. The baseline code obtained from the old pipeline and the baseline code obtained from the new pipeline can be compared using tools such as BCompare to generate a fifth comparison result. Based on this fifth comparison result, the consistency between the code obtained from the old and new pipelines is verified.
[0106] In one possible implementation, when the fifth comparison result shows that the code obtained from the new and old pipelines is the same, a verification pass message can be output indicating that the code obtained from the new and old pipelines is the same. When the fifth comparison result shows that the code obtained from the new and old pipelines is different, the fifth comparison result may include a list of differences between the code obtained from the new pipeline (base code) and the code obtained from the old pipeline (base code), and output a pre-defined verification fail message indicating that the code obtained from the new and old pipelines is different, reminding developers to find the cause of the difference, and allowing them to repeat the above verification process for whether the code obtained from the new and old pipelines is consistent until the verification passes.
[0107] In one possible implementation, before code migration, it can be verified whether the execution results of the new and old pipelines for the same code are the same. If the execution results are the same, the subsequent code migration process can proceed to ensure the smoothness and accuracy of the code migration. Optionally, the verification process for whether the execution results of the new and old pipelines for the same code are the same before code migration can be as follows:
[0108] The baseline code specified by developers in the old codebase is copied to the new codebase. Using the new pipeline corresponding to the new configuration management tool, the baseline code stored in the new codebase is run to generate the third-version artifact. Then, using the old pipeline corresponding to the old configuration management tool, the baseline code stored in the old codebase is run to generate the fourth-version artifact. The third-version artifact and the fourth-version artifact are compared using tools such as BCompare to generate a sixth comparison result. Based on this sixth comparison result, the identicality of the code execution results is verified.
[0109] In one possible implementation, when the sixth comparison result shows that the third and fourth version package artifacts are the same, a verification pass message indicating that the code execution results of the new and old pipelines are the same can be output. When the sixth comparison result shows that the third and fourth version package artifacts are different, the sixth comparison result may include a list of differences between the third and fourth version package artifacts, and output a verification fail message indicating that the code execution results of the new and old pipelines are different, reminding developers to find the cause of the difference. The verification process of whether the code execution results of the same code are the same for the new and old pipelines can be repeated until the verification passes.
[0110] To facilitate understanding, the code migration process provided in this application will be illustrated below through a specific embodiment. Figure 5 The diagram illustrates a fifth code migration process provided in some embodiments, such as... Figure 5 As shown, the process includes the following steps:
[0111] S501: Copy the specified benchmark code from the old codebase to the new codebase; download the benchmark code from the old codebase and download the benchmark code from the new codebase; compare the downloaded benchmark code from the old codebase with the downloaded benchmark code from the new codebase to generate a third comparison result; based on the third comparison result, verify whether the benchmark codes in the old and new codebases are the same; if the verification passes, proceed to S502.
[0112] S502: Based on the new pipeline corresponding to the new configuration management tool, obtain the baseline code from the new code repository; compare the baseline code obtained by the new pipeline with the baseline code stored in the new code repository to generate a fourth comparison result; based on the fourth comparison result, verify whether the code obtained by the new pipeline is correct; if the verification passes, proceed to S503.
[0113] S503: Based on the old pipeline corresponding to the old configuration management tool, obtain the baseline code from the old code repository; compare the baseline code obtained from the old pipeline with the baseline code obtained from the new pipeline, generate the corresponding fifth comparison result, and verify whether the code obtained from the old and new pipelines is consistent based on the fifth comparison result; if the verification passes, proceed to S504.
[0114] S504: Based on the new pipeline operation baseline code corresponding to the new configuration management tool, generate the third version package artifact, and based on the old pipeline operation baseline code corresponding to the old configuration management tool, generate the fourth version package artifact; compare the third version package artifact with the fourth version package artifact to generate the sixth comparison result, and verify whether the code execution results are the same based on the sixth comparison result; if the verification passes, proceed to S505.
[0115] S505: For a specific original target branch in the old configuration management tool that requires code migration, based on the pre-saved correspondence between the original branch and the new branch, determine the corresponding new target branch in the new configuration management tool.
[0116] S506: If it is identified that the target code corresponding to the original target branch has been developed and put into production, then obtain the target code corresponding to the original target branch from the old code repository corresponding to the old configuration management tool; identify the target code as the code corresponding to the new target branch, and save the target code to the new code repository corresponding to the new configuration management tool.
[0117] S507: Download the target code corresponding to the original target branch from the old code repository, and download the code of the new target branch corresponding to the original target branch from the new code repository; compare the downloaded target code corresponding to the original target branch with the code corresponding to the new target branch to generate a second comparison result; based on the second comparison result, verify whether the target code corresponding to the original target branch is the same as the code corresponding to the new target branch.
[0118] S508: Based on the new pipeline corresponding to the new configuration management tool, run the code of the new target branch corresponding to the original target branch to generate the first version package artifact; and based on the old pipeline corresponding to the old configuration management tool, run the target code in the original target branch to generate the second version package artifact; compare the first version package artifact with the second version package artifact to generate the first comparison result, and verify whether the code execution results are the same based on the first comparison result.
[0119] To facilitate understanding, the implementation process of the code migration method provided in this application will be illustrated below with a specific embodiment. The specific implementation process of the code migration work mainly includes three parts: migration preparation work, code migration process, and post-migration verification work. These three parts will be described by example below.
[0120] Migration preparation:
[0121] During migration preparation, a new codebase for the new configuration management tool can be created, and the code migrated to the new codebase (such as the baseline code) can be verified to be identical to the code in the old codebase (such as the baseline code). In the migration preparation process, a baseline codebase can be specified first. Taking Gitee as the new configuration management tool and CC as the old one as an example, a new Gitee codebase can be created. This new Gitee codebase can be empty, and it can be cloned to the local machine. The specified baseline codebase is then downloaded from the old CC codebase to the local machine, copied to the local new Gitee codebase, and finally pushed to the new Gitee codebase server using appropriate add commands (such as `git add`), commit commands (such as `git commit`), and push commands (such as `git push`).
[0122] The process of verifying whether the code migrated to the new codebase is identical to the code in the old codebase can be as follows:
[0123] The baseline code specified in the old codebase such as CC is copied to the new codebase such as Gitee; the baseline code in the old codebase such as CC is downloaded, and the baseline code in the new codebase such as Gitee is also downloaded; using BCompare or similar tools, the downloaded baseline code in the old codebase such as CC is compared with the downloaded baseline code in the new codebase such as Gitee, generating a third comparison result. Based on the third comparison result, it is verified whether the baseline code migrated to the new codebase is the same as the baseline code in the old codebase (for ease of description, referred to as the baseline code in the old and new codebases). The process of verifying the similarity between the baseline code in the old and new codebases based on the third comparison result is the same as in the above embodiment and will not be repeated here.
[0124] In the preparatory work before code migration (migration preparation), a new pipeline for the new configuration management tool can be created, and its ability to accurately acquire code can be verified. The verification process for the new pipeline's ability to accurately acquire code can be as follows:
[0125] The baseline code specified in the old codebase corresponding to the old configuration management tool is copied to the new codebase corresponding to the new configuration management tool. Based on the new pipeline corresponding to the new configuration management tool, the baseline code is obtained from the new codebase. The baseline code obtained by the new pipeline is compared with the baseline code stored in the new codebase using BCompare or similar tools to generate a fourth comparison result. Based on the fourth comparison result, the correctness (accuracy) of the code obtained by the new pipeline is verified. The process of verifying the accuracy of the code obtained by the new pipeline is the same as in the above embodiment and will not be repeated here.
[0126] In the preparatory work before code migration, it is also possible to verify whether the code obtained from the new pipeline is consistent with the code obtained from the old pipeline (the code obtained from the new and old pipelines). The verification process for whether the code obtained from the new and old pipelines is consistent can be as follows:
[0127] The specified baseline code from the old codebase is copied to the new codebase. Based on the old pipeline corresponding to the old configuration management tool, baseline code is obtained from the old codebase; simultaneously, based on the new pipeline corresponding to the new configuration management tool, baseline code is obtained from the new codebase. The baseline code obtained from the old pipeline and the baseline code obtained from the new pipeline are compared, generating a corresponding fifth comparison result. Based on the fifth comparison result, the consistency of the code obtained from the old and new pipelines is verified. The verification process for the consistency of the code obtained from the old and new pipelines is the same as in the above embodiment and will not be repeated here.
[0128] In the preparatory work before code migration, it's also possible to verify whether the execution results of the same code in the new and old pipelines are identical. If the execution results are the same, then proceed with the subsequent code migration process to ensure the smoothness and accuracy of the migration. Optionally, the verification process for whether the execution results of the same code in the new and old pipelines are identical before code migration can be as follows:
[0129] The baseline code specified by developers in the old codebase is copied to the new codebase. Based on the new pipeline corresponding to the new configuration management tool, the baseline code stored in the new codebase is run to generate the third version artifact. Then, based on the old pipeline corresponding to the old configuration management tool, the baseline code stored in the old codebase is run to generate the fourth version artifact. The third and fourth version artifacts are compared using tools such as BCompare to generate a sixth comparison result. Based on this sixth comparison result, the identicality of the code execution results is verified. The verification process for whether the execution results of the same code in the new and old pipelines are identical is the same as in the above embodiment and will not be repeated here.
[0130] Once the migration preparations are complete, the formal code migration process can begin. The code migration process can be as follows:
[0131] In one possible implementation, for a specific original target branch in the old configuration management tool that requires code migration, the corresponding new target branch in the new configuration management tool can be determined based on a pre-saved mapping between original and new branches. If it is identified that the target code corresponding to the original target branch has been developed and deployed, the target code corresponding to the original target branch is retrieved from the old code repository of the old configuration management tool; this target code is then identified as the code corresponding to the new target branch and saved to the new code repository of the new configuration management tool.
[0132] In one possible implementation, the code migration process can be carried out by eliminating code line by line (also known as eliminating code branch by branch). For example, for an original target branch in an old configuration management tool such as CC, after the target code corresponding to the original target branch has been developed and put into production, the target code corresponding to the original target branch can be obtained from the old code repository of the old configuration management tool; this target code can be identified as the code corresponding to the new target branch, and the target code can be saved to the new code repository of the new configuration management tool. At the same time, the code of the original target branch in the old code repository can be eliminated.
[0133] For the line-by-line code migration method, after migrating the code from each original target branch, it is necessary to verify the accuracy of the migration. The verification process after code migration includes:
[0134] Verification is performed to check whether the target code corresponding to the original target branch is the same as the code corresponding to the new target branch, and to check whether the code execution results are the same. The process of verifying whether the target code corresponding to the original target branch is the same as the code corresponding to the new target branch includes:
[0135] For a given original target branch, download the corresponding target code from the old codebase and the corresponding new target branch from the new codebase. Compare the downloaded target code from the original target branch with the corresponding code from the new target branch to generate a second comparison result. Based on the second comparison result, verify whether the target code from the original target branch and the code from the new target branch are identical. The verification process for whether the target code from the original target branch and the code from the new target branch are identical is the same as in the previous embodiment and will not be repeated here.
[0136] The verification process for whether the code execution results are the same includes:
[0137] For a given original target branch, based on the new pipeline corresponding to the new configuration management tool, the code of the new target branch corresponding to the original target branch is run to generate a first version package artifact; and based on the old pipeline corresponding to the old configuration management tool, the target code in the original target branch is run to generate a second version package artifact; the first version package artifact and the second version package artifact are compared to generate a first comparison result; based on the first comparison result, the similarity of the code execution results is verified. The verification process for whether the code execution results are the same is the same as in the above embodiment and will not be repeated here.
[0138] When switching configuration management tools, for new requirements that haven't yet been developed, code applicable to these new requirements can be developed directly within the new codebase of the new configuration management tool, based on the current production code. For code from original target branches already developed in parallel using older configuration management tools like CC, development can continue using those tools. Once development is complete and deployed, the code from each original target branch developed using older tools like CC is migrated to the corresponding new target branch in the new configuration management tool. This completes the code migration process, allowing for subsequent development and deployment using the new configuration management tool, such as Gitee. While this line-by-line code migration approach may extend the overall migration time, it minimizes conflict resolution costs and is a superior choice for systems with large codebases and high levels of parallel development.
[0139] Taking the legacy configuration management tool CC as an example, the process of developing and deploying code based on the legacy configuration management tool can include: developers developing and committing code on their assigned development branches; merging the code from the development branches to the integration branches; tagging the integration branches and using the ICDP pipeline to build the version (obtaining source code, coding, generating version package artifacts, etc.); testing the generated version package artifacts; if the tests are successful, sending the version package artifacts to the production version machine, and making it effective in the production environment on the agreed deployment date. In one possible implementation, the original target branch that needs to be migrated can be any branch within the integration branches.
[0140] In one possible implementation, after switching the configuration management tool to a new one, for example, when updating the current production code version to the version to be deployed, different versions of the code can be compared, and the comparison results can be displayed. This allows developers to confirm the differences between the different versions and prevent issues such as missed commits, code merging, or incorrect code corrections. In another possible implementation, after switching to the new configuration management tool, a new source code comparison script can be built to compare different versions of the code. The comparison of different versions of the code (source code) can then be performed based on this new script. Optionally, the new source code comparison script can include parameters such as the new code repository address, the field identifier tags (referred to as old version field identifiers for ease of description) required for comparison in the current production code version, and the field identifier tags (referred to as new version field identifiers) required for comparison in the version of code to be deployed this time. Based on these parameters, the new source code comparison script can clone the code from the new code repository corresponding to the new code repository address to the local machine, and then compare the code content corresponding to the old version field identifiers with the code content corresponding to the new version field identifiers in the cloned new code repository. The output (displayed) comparison results can include a list of files with differences and the corresponding modification information (which can be in TXT format), and the specific content of the differing files (which can be in HTML format), etc., for developers to refer to and confirm the differences between different versions of code in the comparison results. Optionally, after the new source code comparison script finishes execution, i.e., after the comparison is completed, the new source code comparison script can delete the new code repository stored locally to free up local hard drive space, etc.
[0141] Example 5:
[0142] All embodiments of this application comply with the relevant provisions of national laws and regulations regarding the acquisition, storage, use, and processing of data.
[0143] Based on the same technical concept, this application provides a code migration device. Figure 6 The diagram illustrates a code migration apparatus according to some embodiments, the apparatus comprising:
[0144] Module 61 is used to determine the new target branch corresponding to each original target branch in the new configuration management tool based on the pre-saved correspondence between the original branches and the new branches, for a set number of original target branches in the old configuration management tool that need to be migrated.
[0145] Migration module 62 is used to obtain the target code corresponding to each original target branch from the old code repository corresponding to the old configuration management tool; determine the target code as the code corresponding to the new target branch; and save the target code to the new code repository corresponding to the new configuration management tool.
[0146] In one possible implementation, the determining module 61 is further configured to, for each original target branch, if it is identified that the target code corresponding to the original target branch has been developed and put into production, perform the step of obtaining the target code corresponding to the original target branch from the old code library corresponding to the old configuration management tool for each original target branch.
[0147] In one possible implementation, the device further includes:
[0148] The verification module is used to, for each original target branch, run the code of the new target branch corresponding to the new pipeline of the new configuration management tool to generate a first version package artifact; and run the target code in the original target branch based on the old pipeline of the old configuration management tool to generate a second version package artifact; compare the first version package artifact with the second version package artifact to generate a first comparison result; and verify whether the code execution results are the same based on the first comparison result.
[0149] In one possible implementation, the verification module is further configured to: download the target code corresponding to the original target branch in the old code repository for each original target branch; download the code of the new target branch corresponding to the original target branch in the new code repository; compare the downloaded target code corresponding to the original target branch with the code corresponding to the corresponding new target branch to generate a second comparison result; and verify whether the target code corresponding to the original target branch and the code corresponding to the corresponding new target branch are the same based on the second comparison result.
[0150] In one possible implementation, the determining module 61 is further configured to copy the base code specified in the old code repository to the new code repository; download the base code in the old code repository and download the base code in the new code repository; compare the downloaded base code in the old code repository with the downloaded base code in the new code repository to generate a third comparison result; verify whether the base code in the old and new code repositories is the same based on the third comparison result; if the verification is successful, proceed to the following steps: for the set number of original target branches that need to be migrated in the old configuration management tool, determine the new target branch corresponding to each original target branch in the new configuration management tool based on the pre-saved correspondence between the original branches and the new branches.
[0151] In one possible implementation, the determining module 61 is further configured to: copy the base code specified in the old code repository to the new code repository; obtain the base code from the new code repository based on the new pipeline corresponding to the new configuration management tool; compare the base code obtained by the new pipeline with the base code stored in the new code repository to generate a fourth comparison result; verify whether the code obtained by the new pipeline is correct based on the fourth comparison result; and if the verification is successful, proceed to the following steps: for a set number of original target branches that need to be migrated in the old configuration management tool, determine the new target branch corresponding to each original target branch in the new configuration management tool based on the pre-saved correspondence between the original branches and the new branches.
[0152] In one possible implementation, the determining module 61 is further configured to copy the base code specified in the old code repository to the new code repository; obtain the base code from the old code repository based on the old pipeline corresponding to the old configuration management tool; and obtain the base code from the new code repository based on the new pipeline corresponding to the new configuration management tool; compare the base code obtained by the old pipeline with the base code obtained by the new pipeline to generate a corresponding fifth comparison result; verify whether the code obtained by the old and new pipelines is consistent based on the fifth comparison result; if the verification is successful, proceed to the following steps: for the set number of original target branches that need to be migrated in the old configuration management tool, determine the new target branch corresponding to each original target branch in the new configuration management tool based on the pre-saved correspondence between the original branches and the new branches.
[0153] In one possible implementation, the determining module 61 is further configured to copy the baseline code specified in the old code repository to the new code repository; run the baseline code based on the new pipeline corresponding to the new configuration management tool to generate a third version package artifact, and run the baseline code based on the old pipeline corresponding to the old configuration management tool to generate a fourth version package artifact; compare the third version package artifact with the fourth version package artifact to generate a sixth comparison result; verify whether the code execution results are the same based on the sixth comparison result; if the verification is successful, proceed to the following steps for determining the new target branch corresponding to each original target branch in the new configuration management tool based on the pre-saved correspondence between the original branches and the new branches for a set number of original target branches that need to be migrated in the old configuration management tool.
[0154] Example 6:
[0155] All embodiments of this application comply with the relevant provisions of national laws and regulations regarding the acquisition, storage, use, and processing of data.
[0156] Based on the same technical concept, this application also provides an electronic device. Figure 7 The diagram illustrates a schematic representation of an electronic device structure provided in some embodiments, such as... Figure 7 As shown, the electronic device includes: a processor 71, a communication interface 72, a memory 73, and a communication bus 74, wherein the processor 71, the communication interface 72, and the memory 73 communicate with each other through the communication bus 74.
[0157] The memory 73 stores a computer program, which, when executed by the processor 71, causes the processor 71 to perform the following steps:
[0158] For the set number of original target branches that need to be migrated in the old configuration management tool, based on the pre-saved correspondence between the original branches and the new branches, the corresponding new target branches for each original target branch in the new configuration management tool are determined.
[0159] For each original target branch, obtain the target code corresponding to that original target branch from the old code repository corresponding to the old configuration management tool; determine the target code as the code corresponding to the new target branch, and save the target code to the new code repository corresponding to the new configuration management tool.
[0160] In one possible implementation, the processor 71 is further configured to:
[0161] For each original target branch, if it is identified that the target code corresponding to the original target branch has been developed and put into production, then proceed with the following steps for the set number of original target branches that need to be migrated in the old configuration management tool. Based on the pre-saved correspondence between the original branches and the new branches, determine the new target branches corresponding to each original target branch in the new configuration management tool.
[0162] In one possible implementation, the processor 71 is further configured to:
[0163] For each original target branch, based on the new pipeline corresponding to the new configuration management tool, the code of the new target branch corresponding to the original target branch is run to generate a first version package artifact; and based on the old pipeline corresponding to the old configuration management tool, the target code in the original target branch is run to generate a second version package artifact; the first version package artifact and the second version package artifact are compared to generate a first comparison result, and based on the first comparison result, the code execution results are verified to be the same.
[0164] In one possible implementation, the processor 71 is further configured to:
[0165] For each original target branch, download the target code corresponding to that original target branch from the old code repository, and download the code of the new target branch corresponding to that original target branch from the new code repository; compare the downloaded target code corresponding to the original target branch with the code corresponding to the corresponding new target branch to generate a second comparison result; based on the second comparison result, verify whether the target code corresponding to the original target branch and the code corresponding to the corresponding new target branch are the same.
[0166] In one possible implementation, the processor 71 is further configured to:
[0167] Copy the base code specified in the old codebase to the new codebase;
[0168] Download the baseline code from the old code repository and the baseline code from the new code repository; compare the downloaded baseline code from the old code repository with the downloaded baseline code from the new code repository to generate a third comparison result; based on the third comparison result, verify whether the baseline code in the old and new code repositories is the same; if the verification is successful, proceed to the next step of determining the new target branch corresponding to each original target branch in the new configuration management tool based on the pre-saved correspondence between the original branches and the new branches, for the set number of original target branches that need to be migrated in the old configuration management tool.
[0169] In one possible implementation, the processor 71 is further configured to:
[0170] Copy the base code specified in the old codebase to the new codebase;
[0171] Based on the new pipeline corresponding to the new configuration management tool, the base code is obtained from the new code repository;
[0172] The baseline code obtained by the new pipeline is compared with the baseline code stored in the new code library to generate a fourth comparison result. Based on the fourth comparison result, the correctness of the code obtained by the new pipeline is verified. If the verification is successful, the following steps are taken: for the set number of original target branches that need to be migrated in the old configuration management tool, based on the pre-saved correspondence between the original branches and the new branches, the new target branch corresponding to each original target branch in the new configuration management tool is determined.
[0173] In one possible implementation, the processor 71 is further configured to:
[0174] Copy the base code specified in the old codebase to the new codebase;
[0175] Based on the old pipeline corresponding to the old configuration management tool, the baseline code is obtained from the old code repository; and based on the new pipeline corresponding to the new configuration management tool, the baseline code is obtained from the new code repository.
[0176] The baseline code obtained from the old pipeline is compared with the baseline code obtained from the new pipeline to generate a corresponding fifth comparison result. Based on the fifth comparison result, the consistency of the code obtained from the old and new pipelines is verified. If the verification is successful, the following steps are taken: for the set number of original target branches that need to be migrated in the old configuration management tool, based on the pre-saved correspondence between the original branches and the new branches, the new target branch corresponding to each original target branch in the new configuration management tool is determined.
[0177] In one possible implementation, the processor 71 is further configured to:
[0178] Copy the base code specified in the old codebase to the new codebase;
[0179] The baseline code is run on the new pipeline corresponding to the new configuration management tool to generate the third version package artifact, and the baseline code is run on the old pipeline corresponding to the old configuration management tool to generate the fourth version package artifact.
[0180] The third version package artifact is compared with the fourth version package artifact to generate a sixth comparison result. Based on the sixth comparison result, the code execution results are verified to be the same. If the verification is successful, the following steps are taken: for the set number of original target branches that need to be migrated in the old configuration management tool, based on the pre-saved correspondence between the original branches and the new branches, the new target branches corresponding to each original target branch in the new configuration management tool are determined.
[0181] Example 7:
[0182] All embodiments of this application comply with the relevant provisions of national laws and regulations regarding the acquisition, storage, use, and processing of data.
[0183] Based on the same technical concept, embodiments of this application provide a computer-readable storage medium storing a computer program executable by an electronic device. When the program is run on the electronic device, the electronic device performs the following steps:
[0184] For the set number of original target branches that need to be migrated in the old configuration management tool, based on the pre-saved correspondence between the original branches and the new branches, the corresponding new target branches for each original target branch in the new configuration management tool are determined.
[0185] For each original target branch, obtain the target code corresponding to that original target branch from the old code repository corresponding to the old configuration management tool; determine the target code as the code corresponding to the new target branch, and save the target code to the new code repository corresponding to the new configuration management tool.
[0186] In one possible implementation, before retrieving the target code corresponding to each original target branch from the old code repository corresponding to the old configuration management tool, the method further includes:
[0187] For each original target branch, if the target code corresponding to that original target branch has been developed and put into production, then proceed with the subsequent steps.
[0188] In one possible implementation, the method further includes:
[0189] For each original target branch, based on the new pipeline corresponding to the new configuration management tool, the code of the new target branch corresponding to the original target branch is run to generate a first version package artifact; and based on the old pipeline corresponding to the old configuration management tool, the target code in the original target branch is run to generate a second version package artifact; the first version package artifact and the second version package artifact are compared to generate a first comparison result, and based on the first comparison result, the code execution results are verified to be the same.
[0190] In one possible implementation, the method further includes:
[0191] For each original target branch, download the target code corresponding to that original target branch from the old code repository, and download the code of the new target branch corresponding to that original target branch from the new code repository; compare the downloaded target code corresponding to the original target branch with the code corresponding to the corresponding new target branch to generate a second comparison result; based on the second comparison result, verify whether the target code corresponding to the original target branch and the code corresponding to the corresponding new target branch are the same.
[0192] In one possible implementation, the method further includes determining the corresponding new target branch in the new configuration management tool before each of the predetermined number of original target branches requiring code migration in the old configuration management tool, based on a pre-saved correspondence between original and new branches:
[0193] Copy the base code specified in the old codebase to the new codebase;
[0194] Download the baseline code from the old codebase and the baseline code from the new codebase; compare the downloaded baseline code from the old codebase with the downloaded baseline code from the new codebase to generate a third comparison result; based on the third comparison result, verify whether the baseline code in the old and new codebases is the same; if the verification passes, proceed to the next steps.
[0195] In one possible implementation, the method further includes determining the corresponding new target branch in the new configuration management tool before each of the predetermined number of original target branches requiring code migration in the old configuration management tool, based on a pre-saved correspondence between original and new branches:
[0196] Copy the base code specified in the old codebase to the new codebase;
[0197] Based on the new pipeline corresponding to the new configuration management tool, the base code is obtained from the new code repository;
[0198] The baseline code obtained by the new pipeline is compared with the baseline code stored in the new code library to generate a fourth comparison result. Based on the fourth comparison result, the correctness of the code obtained by the new pipeline is verified. If the verification is successful, the subsequent steps are performed.
[0199] In one possible implementation, the method further includes determining the corresponding new target branch in the new configuration management tool before each of the predetermined number of original target branches requiring code migration in the old configuration management tool, based on a pre-saved correspondence between original and new branches:
[0200] Copy the base code specified in the old codebase to the new codebase;
[0201] Based on the old pipeline corresponding to the old configuration management tool, the baseline code is obtained from the old code repository; and based on the new pipeline corresponding to the new configuration management tool, the baseline code is obtained from the new code repository.
[0202] The baseline code obtained from the old pipeline is compared with the baseline code obtained from the new pipeline to generate a corresponding fifth comparison result. Based on the fifth comparison result, the consistency of the code obtained from the old and new pipelines is verified. If the verification is successful, the subsequent steps are performed.
[0203] In one possible implementation, the method further includes determining the corresponding new target branch in the new configuration management tool before each of the predetermined number of original target branches requiring code migration in the old configuration management tool, based on a pre-saved correspondence between original and new branches:
[0204] Copy the base code specified in the old codebase to the new codebase;
[0205] The baseline code is run on the new pipeline corresponding to the new configuration management tool to generate the third version package artifact, and the baseline code is run on the old pipeline corresponding to the old configuration management tool to generate the fourth version package artifact.
[0206] The third version package artifact is compared with the fourth version package artifact to generate a sixth comparison result. Based on the sixth comparison result, the code execution results are verified to be the same. If the verification is successful, the subsequent steps are performed.
[0207] The aforementioned computer-readable storage medium can be any available medium or data storage device that can be accessed by the processor in an electronic device, including but not limited to magnetic storage such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO), optical storage such as CDs, DVDs, BDs, HVDs, etc., and semiconductor storage such as ROMs, EPROMs, EEPROMs, non-volatile memory (NAND flash), solid-state drives (SSDs), etc.
[0208] Based on the same technical concept, this application provides a computer program product, which includes: computer program code, which, when run on a computer, causes the computer to implement the method described in any of the above-described method embodiments applied to electronic devices.
[0209] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof, or in whole or in part, as a computer program product. The computer program product includes one or more computer instructions, which, when loaded and executed on a computer, generate, in whole or in part, the processes or functions described in the embodiments of this application.
[0210] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0211] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0212] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0213] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0214] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. A code migration method, characterized in that, The method includes: For the set number of original target branches that need to be migrated in the old configuration management tool, based on the pre-saved correspondence between the original branches and the new branches, the corresponding new target branches for each original target branch in the new configuration management tool are determined. For each original target branch, if it is identified that the target code corresponding to the original target branch has been developed and put into production, the target code corresponding to the original target branch is obtained from the old code repository corresponding to the old configuration management tool; the target code is identified as the code corresponding to the new target branch, and the target code is saved to the new code repository corresponding to the new configuration management tool.
2. The method according to claim 1, characterized in that, The method further includes: For each original target branch, based on the new pipeline corresponding to the new configuration management tool, the code of the new target branch corresponding to the original target branch is run to generate a first version package artifact; and based on the old pipeline corresponding to the old configuration management tool, the target code in the original target branch is run to generate a second version package artifact; the first version package artifact and the second version package artifact are compared to generate a first comparison result, and based on the first comparison result, the code execution results are verified to be the same.
3. The method according to claim 1, characterized in that, The method further includes: For each original target branch, download the target code corresponding to that original target branch from the old code repository, and download the code of the new target branch corresponding to that original target branch from the new code repository; compare the downloaded target code corresponding to the original target branch with the code corresponding to the corresponding new target branch to generate a second comparison result; based on the second comparison result, verify whether the target code corresponding to the original target branch and the code corresponding to the corresponding new target branch are the same.
4. The method according to claim 1, characterized in that, The method further includes determining the corresponding new target branch in the new configuration management tool before each original target branch in the new configuration management tool, based on a pre-saved correspondence between the original and new branches, for a set number of original target branches that need code migration in the old configuration management tool. Copy the base code specified in the old codebase to the new codebase; Download the baseline code from the old codebase and the baseline code from the new codebase; compare the downloaded baseline code from the old codebase with the downloaded baseline code from the new codebase to generate a third comparison result; based on the third comparison result, verify whether the baseline code in the old and new codebases is the same; if the verification passes, proceed to the next steps.
5. The method according to claim 1, characterized in that, The method further includes determining the corresponding new target branch in the new configuration management tool before each original target branch in the new configuration management tool, based on a pre-saved correspondence between the original and new branches, for a set number of original target branches that need code migration in the old configuration management tool. Copy the base code specified in the old codebase to the new codebase; Based on the new pipeline corresponding to the new configuration management tool, the base code is obtained from the new code repository; The baseline code obtained by the new pipeline is compared with the baseline code stored in the new code library to generate a fourth comparison result. Based on the fourth comparison result, the correctness of the code obtained by the new pipeline is verified. If the verification is successful, the subsequent steps are performed.
6. The method according to claim 1, characterized in that, The method further includes determining the corresponding new target branch in the new configuration management tool before each original target branch in the new configuration management tool, based on a pre-saved correspondence between the original and new branches, for a set number of original target branches that need code migration in the old configuration management tool. Copy the base code specified in the old codebase to the new codebase; Based on the old pipeline corresponding to the old configuration management tool, the baseline code is obtained from the old code repository; and based on the new pipeline corresponding to the new configuration management tool, the baseline code is obtained from the new code repository. The baseline code obtained from the old pipeline is compared with the baseline code obtained from the new pipeline to generate a corresponding fifth comparison result. Based on the fifth comparison result, the consistency of the code obtained from the old and new pipelines is verified. If the verification is successful, the subsequent steps are performed.
7. The method according to any one of claims 1-6, characterized in that, The method further includes determining the corresponding new target branch in the new configuration management tool before each original target branch in the new configuration management tool, based on a pre-saved correspondence between the original and new branches, for a set number of original target branches that need code migration in the old configuration management tool. Copy the base code specified in the old codebase to the new codebase; The baseline code is run on the new pipeline corresponding to the new configuration management tool to generate the third version package artifact, and the baseline code is run on the old pipeline corresponding to the old configuration management tool to generate the fourth version package artifact. The third version package artifact is compared with the fourth version package artifact to generate a sixth comparison result. Based on the sixth comparison result, the code execution results are verified to be the same. If the verification is successful, the subsequent steps are performed.
8. A code migration device, characterized in that, The device includes: The determination module is used to determine the new target branch corresponding to each original target branch in the new configuration management tool based on a pre-saved correspondence between the original branches and the new branches, for a set number of original target branches in the old configuration management tool that need to be migrated. The migration module is used to obtain the target code corresponding to each original target branch from the old code repository corresponding to the old configuration management tool; determine the target code as the code corresponding to the new target branch; and save the target code to the new code repository corresponding to the new configuration management tool. The determining module is further configured to, for each original target branch, if it is identified that the target code corresponding to the original target branch has been developed and put into production, then perform the step of obtaining the target code corresponding to the original target branch from the old code library corresponding to the old configuration management tool for each original target branch.
9. The apparatus according to claim 8, characterized in that, The device further includes: The verification module is used to, for each original target branch, run the code of the new target branch corresponding to the new pipeline of the new configuration management tool to generate a first version package artifact; and run the target code in the original target branch based on the old pipeline of the old configuration management tool to generate a second version package artifact; compare the first version package artifact with the second version package artifact to generate a first comparison result; and verify whether the code execution results are the same based on the first comparison result.
10. The apparatus according to claim 8, characterized in that, The device further includes: The verification module is used to download the target code corresponding to the original target branch in the old code repository for each original target branch, and download the code of the new target branch corresponding to the original target branch in the new code repository; compare the downloaded target code corresponding to the original target branch with the code corresponding to the corresponding new target branch to generate a second comparison result; and verify whether the target code corresponding to the original target branch and the code corresponding to the corresponding new target branch are the same based on the second comparison result.
11. The apparatus according to claim 8, characterized in that, The determining module is further configured to copy the base code specified in the old code repository to the new code repository; download the base code in the old code repository, and download the base code in the new code repository; The benchmark code in the downloaded old code library is compared with the benchmark code in the downloaded new code library to generate a third comparison result. Based on the third comparison result, it is verified whether the benchmark code in the old and new code libraries is the same. If the verification is successful, the next step is to determine the corresponding new target branch in the new configuration management tool for each original target branch that needs to be migrated, based on the pre-saved correspondence between the original branches and the new branches.
12. The apparatus according to claim 8, characterized in that, The determining module is further configured to copy the base code specified in the old code repository to the new code repository; and to obtain the base code from the new code repository based on the new pipeline corresponding to the new configuration management tool. The baseline code obtained by the new pipeline is compared with the baseline code stored in the new code library to generate a fourth comparison result. Based on the fourth comparison result, the correctness of the code obtained by the new pipeline is verified. If the verification is successful, the next step is to determine the corresponding new target branch in the new configuration management tool for each original target branch that needs to be migrated, based on the pre-saved correspondence between the original branches and the new branches.
13. The apparatus according to claim 8, characterized in that, The determining module is further configured to copy the base code specified in the old code repository to the new code repository; obtain the base code from the old code repository based on the old pipeline corresponding to the old configuration management tool; and obtain the base code from the new code repository based on the new pipeline corresponding to the new configuration management tool. The baseline code obtained from the old pipeline is compared with the baseline code obtained from the new pipeline to generate a corresponding fifth comparison result. Based on the fifth comparison result, the consistency of the code obtained from the old and new pipelines is verified. If the verification is successful, the next step is to determine the corresponding new target branch in the new configuration management tool for each original target branch that needs to be migrated, based on the pre-saved correspondence between the original branches and the new branches.
14. The apparatus according to any one of claims 8-13, characterized in that, The determining module is further configured to copy the base code specified in the old code repository to the new code repository; run the base code based on the new pipeline corresponding to the new configuration management tool to generate a third version package artifact; and run the base code based on the old pipeline corresponding to the old configuration management tool to generate a fourth version package artifact. The third version package artifact is compared with the fourth version package artifact to generate a sixth comparison result. Based on the sixth comparison result, it is verified whether the code execution results are the same. If the verification is successful, the next step is to determine the corresponding new target branch in the new configuration management tool for each original target branch that needs to be migrated, based on the pre-saved correspondence between the original branches and the new branches.
15. An electronic device, characterized in that, The electronic device includes at least a processor and a memory, the processor being configured to implement the steps of the method as described in any one of claims 1-7 when executing a computer program stored in the memory.
16. A computer-readable storage medium, characterized in that, It stores a computer program that, when executed by a processor, implements the steps of the method as described in any one of claims 1-7.
17. A computer program product, characterized in that, The computer program product includes: computer program code, which, when run on a computer, causes the computer to perform the steps of the method as described in any one of claims 1-7.
Citation Information
Patent Citations
Code migration method, equipment and storage medium
CN111008037A