Cross-version library synchronization method and device, computer equipment, readable storage medium and program product
Through the use of configuration files and password hash functions, the problem of missing synchronization and misplacement in version library synchronization is solved, automatic synchronization is realized, and synchronization accuracy and data consistency are improved.
Patent Information
- Application Number
- CN202410875964.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-02
- Publication Date
- 2024-08-23
AI Technical Summary
During the repository synchronization process, manual synchronization can easily lead to missing synchronization and synchronization of wrong file locations, affecting synchronization accuracy.
The configuration file and password hash function are used to compare the file information in the version library. By calculating the hash code and position comparison of the file, it is determined whether the synchronization is successful and automatic synchronization is achieved.
It improves the accuracy of cross-repository synchronization, reduces manual errors, and ensures data integrity and synchronization consistency.
Smart Images

Figure CN118535542A
Abstract
Description
Technical Field
[0001] The present application relates to the field of big data technology, and in particular to a cross-version library synchronization method, apparatus, computer equipment, readable storage medium, and program product. Background Art
[0002] With the continuous adjustment and optimization of the code structure in the version library, when the version library is adjusted or optimized on a large scale, a second version library will be established to synchronize the content of the original version library to the second version library. Since the content of the first version library has not completed the development of the previous project, and the subsequent project depends on the previous code, the code modification content during the parallel project needs to synchronize the updated content in the original version library to the second version library.
[0003] In the related art, manual synchronization is used for code synchronization. The code in the original version library may not be processed until some time later, and different file locations need to be processed. Therefore, the manual synchronization method may cause problems such as missing synchronization and synchronizing the wrong file location. Summary of the invention
[0004] Based on this, it is necessary to provide a cross-version library synchronization method, device, computer equipment, readable storage medium and program product that can improve the accuracy of cross-version library synchronization in response to the above technical problems.
[0005] In a first aspect, the present application provides a cross-version library synchronization method, including:
[0006] Synchronize the first target branch in the first version library according to the configuration file to obtain the second target branch in the second version library;
[0007] By using a cryptographic hash function, first file information of each file included in the first target branch and second file information of each file included in the second target branch are calculated to obtain a first cryptographic hash code of the first file information and a second cryptographic hash code of the second file information respectively corresponding to each file;
[0008] If the first cryptographic hash code is consistent with the second cryptographic hash code, and the position comparison result of each file meets the preset position condition in the configuration file, it is determined that the synchronization of the second version library is successful.
[0009] In one embodiment, the first file information includes the branch name, file name and capacity information of each file in the first target branch, and the second file information includes the branch name, file name and capacity information of each file in the second target branch.
[0010] In one embodiment, the first file information of each file included in the first target branch and the second file information of each file included in the second target branch are calculated by using a cryptographic hash function to obtain a first cryptographic hash code of the first file information and a second cryptographic hash code of the second file information corresponding to each file, respectively, including:
[0011] Based on a cryptographic hash function, the branch name, the file name, and the capacity information of each file in the first target branch are calculated to obtain the first cryptographic hash code corresponding to each file;
[0012] Based on the cryptographic hash function, the branch name, the file name and the capacity information of each file in the second target branch are calculated to obtain the second cryptographic hash code corresponding to each file.
[0013] In one of the embodiments, the configuration file includes a first target location of each file in the first target branch in the first version library and a second target location of each file in the second target branch in the second version library;
[0014] The step of determining whether the position comparison result of each file meets the preset position condition in the configuration file includes:
[0015] Obtaining a first actual location of each file in the first target branch in the first version repository and a second actual location of each file in the second target branch in the second version repository;
[0016] Comparing the first target position with the first actual position to obtain a first comparison result; comparing the second target position with the second actual position to obtain a second comparison result;
[0017] If the first comparison result indicates that the first target position is consistent with the first actual position and the second comparison result indicates that the second target position is consistent with the second actual position, then the preset position condition in the configuration file is met.
[0018] In one of the embodiments, the configuration file further includes a framework adjustment strategy for the first target branch;
[0019] The step of synchronizing the first target branch in the first version repository according to the configuration file to obtain the second target branch in the second version repository includes:
[0020] If the second version library is an empty version library and the configuration is complete, obtain the first target branch in the first version library;
[0021] The first target branch is migrated based on the branch migration command and the framework adjustment strategy to obtain a second target branch in the second version library.
[0022] In one of the embodiments, the configuration file also includes incremental information of each file in the first target branch;
[0023] The step of synchronizing the first target branch in the first version repository according to the configuration file to obtain the second target branch in the second version repository includes:
[0024] If the first target branch of the first version library satisfies that there is a file update and the second target branch of the second version library does not have a file update, obtain the first target branch in the first version library;
[0025] The first target branch is synchronized based on the second target position in the configuration file, the branch synchronization command, and the incremental information in each file to obtain the second target branch in the second version library.
[0026] In a second aspect, the present application also provides a cross-version library synchronization device, including:
[0027] A synchronization module, used to synchronize the first target branch in the first version library according to the configuration file to obtain the second target branch in the second version library;
[0028] a calculation module, configured to calculate, by a cryptographic hash function, first file information of each file contained in the first target branch and second file information of each file contained in the second target branch, respectively, to obtain a first cryptographic hash code of the first file information and a second cryptographic hash code of the second file information respectively corresponding to each file;
[0029] The determination module is configured to determine that the synchronization of the second version library is successful if the first cryptographic hash code is consistent with the second cryptographic hash code and the position comparison result of each file meets the preset position condition in the configuration file.
[0030] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0031] Synchronize the first target branch in the first version library according to the configuration file to obtain the second target branch in the second version library;
[0032] By using a cryptographic hash function, first file information of each file included in the first target branch and second file information of each file included in the second target branch are calculated to obtain a first cryptographic hash code of the first file information and a second cryptographic hash code of the second file information respectively corresponding to each file;
[0033] If the first cryptographic hash code is consistent with the second cryptographic hash code, and the position comparison result of each file meets the preset position condition in the configuration file, it is determined that the synchronization of the second version library is successful.
[0034] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:
[0035] Synchronize the first target branch in the first version library according to the configuration file to obtain the second target branch in the second version library;
[0036] By using a cryptographic hash function, first file information of each file included in the first target branch and second file information of each file included in the second target branch are calculated to obtain a first cryptographic hash code of the first file information and a second cryptographic hash code of the second file information respectively corresponding to each file;
[0037] If the first cryptographic hash code is consistent with the second cryptographic hash code, and the position comparison result of each file meets the preset position condition in the configuration file, it is determined that the synchronization of the second version library is successful.
[0038] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:
[0039] Synchronize the first target branch in the first version library according to the configuration file to obtain the second target branch in the second version library;
[0040] By using a cryptographic hash function, first file information of each file included in the first target branch and second file information of each file included in the second target branch are calculated to obtain a first cryptographic hash code of the first file information and a second cryptographic hash code of the second file information respectively corresponding to each file;
[0041] If the first cryptographic hash code is consistent with the second cryptographic hash code, and the position comparison result of each file meets the preset position condition in the configuration file, it is determined that the synchronization of the second version library is successful.
[0042] The above-mentioned cross-version library synchronization method, device, computer equipment, readable storage medium and program product synchronize the first target branch in the first version library to the second target branch of the second version library by using a configuration file, and calculate the first file information and the second file information of each file based on a cryptographic hash function to obtain the first cryptographic hash code and the second cryptographic hash code of each file, compare the first cryptographic hash code and the second cryptographic hash code of each file one by one and obtain the position information of each file before and after synchronization, so as to determine that each file in the second target branch in the second version library is synchronized successfully, realize the data integrity verification before and after the version library synchronization, and then achieve automatic synchronization across version libraries, thereby improving the accuracy of cross-version synchronization. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0044] Figure 1 A schematic diagram of a process flow of a cross-version repository synchronization method in one embodiment;
[0045] Figure 2 A schematic diagram of a process flow of a cross-version repository synchronization method in one embodiment;
[0046] Figure 3 It is a structural block diagram of a cross-version library synchronization device in one embodiment;
[0047] Figure 4 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0048] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0049] In one embodiment, Figure 1 As shown, a cross-version library synchronization method is provided. This embodiment uses the method applied to a terminal as an example for illustration. It can be understood that the method can also be applied to a server, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. In this embodiment, the method includes the following steps:
[0050] Step 101: Synchronize the first target branch in the first version library according to the configuration file to obtain the second target branch in the second version library.
[0051] The configuration file may include information to be updated in the version library, and the configuration file may be stored in a database. The information to be updated may include adjustment or optimization strategies for the code framework in the version library or modification strategies for the code in the version library, etc. The first version library may be a version library to be synchronized. For example, the first version library may be GIT (distributed version control system). The first target branch may be a branch to be synchronized in the first version library to be synchronized. The second version library may be a synchronized version library. For example, the second version library may be GIT (distributed version control system). The second target branch may be a synchronized branch in the synchronized version library.
[0052] Specifically, when the version library needs to be synchronized, the terminal can obtain the branch to be synchronized (the first target branch) in the first version library, and determine whether to adjust the framework of the file in the first target branch or modify the content of the file according to the content of the configuration file. The terminal can synchronize the first target branch in the first version library based on the adjustment or optimization strategy of the code framework in the version library and / or the modification strategy of the code in the version library to obtain the second target branch in the second version library.
[0053] Step 102: Calculate the first file information of each file contained in the first target branch and the second file information of each file contained in the second target branch by using a cryptographic hash function to obtain a first cryptographic hash code of the first file information and a second cryptographic hash code of the second file information corresponding to each file.
[0054] Among them, the cryptographic hash function can be a SHA-1 function, which is an encrypted hash function. The content in the file can be generated into a cryptographic hash code through its SHA-1 function. The cryptographic hash code can be composed of 40 hexadecimal digits, and the output length is 160 bits; if the cryptographic hash codes of two files are the same, it is determined that the contents of the two files are exactly the same. The file information can represent the parameters in the file corresponding to the file information; for example, the first file information and the second file information can represent the parameters in each file. The first cryptographic hash code can be a SHA-1 code obtained by processing the file in the first target branch, which is used to uniquely identify the content of the file in the first target branch; the second cryptographic hash code can be a SHA-1 code, which is used to uniquely identify the content of the file in the second target branch.
[0055] Specifically, the terminal can use a cryptographic hash function to calculate the first target branch in each file in the first target branch in the first version library, and obtain a first cryptographic hash code corresponding to each file. The terminal can use a cryptographic hash function to calculate the second target branch in each file in the second target branch in the second version library, and obtain a second cryptographic hash code corresponding to each file.
[0056] Step 103: If the first cryptographic hash code and the second cryptographic hash code are consistent, and the position comparison results of each file meet the preset position conditions in the configuration file, it is determined that the second version library is synchronized successfully.
[0057] The configuration file may include the location of each file in the first target branch in the first version library and the location of each file in the second target branch in the second version library. The preset location condition is used to determine whether the actual location of each file is the same as the preset location.
[0058] Specifically, if the first cryptographic hash code and the second cryptographic hash code are consistent, the terminal can determine that the contents of each file in the first target branch are consistent with those of each file in the second target branch, that is, the contents of the corresponding files before and after synchronization are consistent, and if the positions of each file in the first target branch in the first version library and the positions of each file in the second target branch in the second version library meet the preset position conditions, the terminal can determine that the content and position of each file in the second target branch in the second version library are successfully synchronized.
[0059] In the above-mentioned cross-version repository synchronization method, a configuration file is used to synchronize the first target branch in the first version repository to the second target branch of the second version repository, and the first file information and the second file information of each file are calculated based on a cryptographic hash function to obtain the first cryptographic hash code and the second cryptographic hash code of each file. The first cryptographic hash code and the second cryptographic hash code of each file are compared one by one and the position information of each file before and after synchronization is obtained. It can be determined that each file in the second target branch in the second version repository is synchronized successfully, and the data integrity check before and after the version repository synchronization is realized, thereby achieving automatic synchronization across version repositories, thereby improving the accuracy of cross-version synchronization.
[0060] In an exemplary embodiment, the first file information includes the branch name, file name and capacity information of each file in the first target branch, and the second file information includes the branch name, file name and capacity information of each file in the second target branch.
[0061] The file information may reflect information such as the branch name where the file is located, the file name, and the capacity information of the file. The capacity information of the file may refer to the size of the file.
[0062] In an exemplary embodiment, step 102 includes:
[0063] Based on the cryptographic hash function, the branch name, file name and capacity information of each file in the first target branch are calculated to obtain the first cryptographic hash code corresponding to each file; based on the cryptographic hash function, the branch name, file name and capacity information of each file in the second target branch are calculated to obtain the second cryptographic hash code corresponding to each file.
[0064] Specifically, the terminal uses the cryptographic hash function to calculate the SHA-1 code of each file in the following steps: first, convert the text in the file into a byte sequence, that is, convert the text string into a byte sequence encoded in UTF-8 (UCS Transformation Format 8, variable-length character encoding); then fill the byte sequence to the input block size of the SHA-1 algorithm, which is usually 64 bytes. If the text length is less than 64 bytes, fill it with 0 at the end until it reaches 64 bytes; set an initial hash value of 160 bits, usually filled with 0. At the same time, set a variable K, whose value is 65536 (2 to the 16th power); divide the byte sequence into groups of 64 bits, and perform a total of 8 cycles. In each cycle, perform the following operations: a. XOR the current 64-bit byte sequence with the initial hash value. b. XOR the result with K. c. Group the result into 160 bits, each group of 16 bits, and fill the less than 16 bits with 0 at the end. Then convert each group of 16 bits into a hexadecimal character to obtain a hexadecimal string. d. The obtained hexadecimal string is concatenated with the hexadecimal string of the previous cycle to obtain a new hexadecimal string. After the last cycle, the obtained hexadecimal string is the SHA-1 code corresponding to each file.
[0065] In an exemplary embodiment, the step of determining whether the position comparison result of each file satisfies the preset position condition in the configuration file includes:
[0066] Obtain a first actual position of each file in the first target branch in the first version library and a second actual position of each file in the second target branch in the second version library; compare the first target position with the first actual position to obtain a first comparison result; compare the second target position with the second actual position to obtain a second comparison result; if the first comparison result indicates that the first target position is consistent with the first actual position and the second comparison result indicates that the second target position is consistent with the second actual position, then the preset position condition in the configuration file is met.
[0067] The first actual location is the actual path of each file in the first target branch in the first version library; the second actual location is the actual path of each file in the second target branch in the second version library. The configuration file may include the first target location of each file in the first target branch in the first version library and the second target location of each file in the second target branch in the second version library; the first target location is the target path of each file in the first target branch in the first version library, and the second target location is the target path of each file in the second target branch in the second version library.
[0068] Specifically, the terminal can obtain the actual location of each file in the first target branch in the first version library and the actual location of each file in the second target branch in the second version library; if the actual location is consistent with the target location in the configuration file, it can be determined that the files in the first target branch are synchronized with the files in the second target branch, thereby realizing the verification of the synchronized position and improving the accuracy of cross-version library synchronization.
[0069] In an exemplary embodiment, synchronizing a first target branch in a first version library according to a configuration file to obtain a second target branch in a second version library includes:
[0070] If the second version library is an empty version library and the configuration is complete, the first target branch in the first version library is obtained; the first target branch is migrated based on the branch migration command and the framework adjustment strategy to obtain the second target branch in the second version library.
[0071] Among them, an empty version library can mean that there is no content in the second version library, a complete configuration can mean that the second version library includes the initial configuration information in the second version library and the initial branch in the second version library, etc., and the branch migration command can be a command prompt (CMD); the configuration file also includes a framework adjustment strategy for the first target branch, and the framework adjustment strategy can include various adjustments or optimizations to the framework in the version library, etc.
[0072] Specifically, initialization settings need to be performed before migration. Exemplarily, the process of initialization settings of the terminal may include: the terminal determines the address of the first version library, the address of the second version library, the branch of the first version library, the account and password of the version library, the correspondence between the files / folders before and after migration in the first version library and the second version library, and the correspondence between the files / folders before and after migration in the first version library and the second version library can be stored in a table file or in a database.
[0073] Specifically, if the second version library is an empty version library and the configuration is complete, it meets the migration conditions. Specifically, the terminal opens two version library client windows, uses the git checkout release_20240119 command to pull the latest files of the specified branch on the first version library, uses the git branchrelease_20240119 command to create a new branch based on the default branch (master branch) in the second version library, and then uses the git checkout release_20240119 command to switch the second version library to the new branch. The terminal adjusts the strategy according to the framework of the configuration file, uses the CMD command to migrate and executes line by line: the terminal copies the path of the target branch in the first version library with xcopy, and the path of the second version library can be / s / e, where / s means copying the entire directory tree, including empty directories; / e means copying all subdirectories and files, including empty directories and hidden files. It should be understood that this is only used for explanation and does not constitute a specific limitation. As shown in Table 1, Table 1 shows the file names in the first version library and the second version library before and after the migration, the first version library name, the first target branch name, the actual location of the files in the first version library, the second version library name, the second target branch name, and the actual location of the files in the second version library. It should be understood that this is only used for explanation and does not constitute a specific limitation.
[0074] Table 1
[0075]
[0076] In one example, when the version library needs to be migrated, the terminal determines the latest code of the current latest branch of the first version library (for example, release_20240119), creates the same branch name (for example, release_20240119) under the second version library, and migrates the latest file of the current latest branch of the first version library (for example, release_20240119) to the branch of the same name (for example, release_20240119) of the second version library. According to the framework optimization or adjustment strategy, the file location is modified without modifying the file content, and the SHA-1 code of each file does not change.
[0077] In one example, the second version library can be updated according to demand. For example, if the terminal detects that the second version library needs to modify the file content, the terminal can create a new branch (such as release_20240218) based on the branch with the same name (such as release_20240119) under the second version library, and then modify the file content on the new branch (such as release_20240218). If there are new monthly requirements, such as requirements for February, the terminal can create a new branch (such as release_20240218) in the second version library and modify it. If it is a modification of existing requirements, the terminal needs to modify the branch of the first version library (such as release_20240119).
[0078] In one example, the terminal can determine the file locations of files with the same SHA-1 code on the first version library and the second version library. The SHA-1 code of the file on the latest branch of the first version library (for example, release_20240119) is consistent with the SHA-1 code of the file on the branch with the same name of the second version library (for example, release_20240119). The location of each file is determined so that if there are modifications in the latest branch of the first version library (for example, release_20240119), the first version library can also be modified, for example, the modifications can be synchronized from the branch in the first version library (for example, release_20240119) to the branch in the second version library (for example, release_20240119).
[0079] In one example, the terminal can use the git commit command to enable the commit area to obtain the newly added files in the corresponding branch in the second version library and / or the adjustment information of the file position in the branch. The terminal can use the git push command to submit the newly added file content and / or the adjustment information of the file position in the branch corresponding to the second version library to the server, so that the updated file content and / or the adjustment information of the file position in the second version library can be displayed on the server side.
[0080] Specifically, the terminal may generate a record file after the version library is migrated, and the record file may store the file position and sha-1 code of each file in the branch before and after the migration.
[0081] In an exemplary embodiment, synchronizing a first target branch in a first version library according to a configuration file to obtain a second target branch in a second version library includes:
[0082] If the first target branch of the first version library satisfies the requirement that there are file updates and there are no file updates in the second target branch of the second version library, then the first target branch in the first version library is obtained; based on the second target position in the configuration file, the branch synchronization command and the incremental information in each file, the first target branch is synchronized to obtain the second target branch in the second version library.
[0083] Among them, the branch synchronization command can be a command prompt (CMD); the configuration file also includes incremental information of each file in the first target branch, and the incremental information is the updated content of the file in the target branch. The incremental information can be generated by comparing the current version library submission number with the corresponding submission version number during the last synchronization; the version number is an identifier generated after each version library code synchronization is completed.
[0084] Specifically, if the first target branch of the first version library satisfies the requirement of file update and the second target branch of the second version library has no file update, the terminal determines that the cross-version synchronization condition is met; the terminal opens two client windows and uses the git checkout release_20240119 command to pull the latest files of the first target branch in the first version library respectively; the terminal determines the second target branch corresponding to the first target branch according to the position of the files before and after synchronization; the terminal can use the CMD command to execute line by line: xcopy first version library path second version library path / s / e / y, where / s means copying the entire directory tree, including empty directories; / e means copying all subdirectories and files, including empty directories and hidden files; / y means not prompting for confirmation when overwriting the target file. After synchronization, the client submission area of the second version library can obtain incremental updates, and the terminal uses the git commit command to commit.
[0085] In one example, after the terminal determines that the second version library is successfully synchronized locally, the terminal uses the git push command to push the content in the first version library.
[0086] In an exemplary embodiment, Figure 2 As shown, Figure 2 A cross-version synchronization method is provided, which specifically includes the following steps:
[0087] The terminal obtains the latest code of the first target branch in the first version library and determines the conditions satisfied by the latest code; if the migration condition is satisfied, the terminal obtains the first target branch in the first version library, establishes a branch name identical to the first target branch of the first version library in the second version library, migrates the first target branch based on the branch migration command and the framework adjustment strategy, and obtains the second target branch in the second version library; if the synchronization condition is satisfied, the terminal obtains the first target branch in the first version library; synchronizes the first target branch based on the second target position in the configuration file, the branch synchronization command, and the incremental information in each file, and obtains the second target branch in the second version library; the terminal calculates the SHA-1 code of each file of the first target branch in the first version library and the SHA-1 code of each file of the second target branch in the second version library; the terminal records the SHA-1 code of each file after the migration is successful and the paths before and after the migration; if the first cryptographic hash code and the second cryptographic hash code are consistent, and the position comparison result of each file meets the preset position condition in the configuration file, the terminal determines that the synchronization of the second version library is successful, and records the submitted version number of the synchronized version library.
[0088] In summary, this embodiment can reduce the burden on developers and the problems that are prone to occur in manual operations (such as missed synchronization, synchronization of wrong file locations, etc.), improve the efficiency of branch synchronization and / or migration operations across version libraries after completing version library migration, reduce risks other than coding, and thus automatically complete the synchronization operation.
[0089] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0090] Based on the same inventive concept, the embodiment of the present application also provides a cross-version library synchronization device for implementing the cross-version library synchronization method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more cross-version library synchronization device embodiments provided below can refer to the limitations of the cross-version library synchronization method above, and will not be repeated here.
[0091] In an exemplary embodiment, Figure 3 As shown, a cross-version library synchronization device is provided. The cross-version library synchronization device 30 includes: a synchronization module 31, a calculation module 32 and a determination module 33, wherein:
[0092] A synchronization module 31, configured to synchronize the first target branch in the first version library according to the configuration file to obtain the second target branch in the second version library;
[0093] The calculation module 32 is used to calculate the first file information of each file contained in the first target branch and the second file information of each file contained in the second target branch by using a cryptographic hash function to obtain a first cryptographic hash code of the first file information and a second cryptographic hash code of the second file information respectively corresponding to each file;
[0094] The determination module 33 is configured to determine that the synchronization of the second version library is successful if the first cryptographic hash code and the second cryptographic hash code are consistent and the position comparison result of each file meets the preset position condition in the configuration file.
[0095] In one embodiment, the first file information includes the branch name, file name and capacity information of each file in the first target branch, and the second file information includes the branch name, file name and capacity information of each file in the second target branch.
[0096] In one embodiment, the calculation module 32 is used to calculate the branch name, file name and capacity information of each file in the first target branch based on the cryptographic hash function to obtain a first cryptographic hash code corresponding to each file;
[0097] Based on the cryptographic hash function, the branch name, file name and capacity information of each file in the second target branch are calculated to obtain a second cryptographic hash code corresponding to each file.
[0098] In one of the embodiments, the configuration file includes a first target location of each file in the first target branch in the first version library and a second target location of each file in the second target branch in the second version library;
[0099] The determination module 33 is further used to obtain a first actual position of each file in the first target branch in the first version library and a second actual position of each file in the second target branch in the second version library;
[0100] Comparing the first target position with the first actual position to obtain a first comparison result; comparing the second target position with the second actual position to obtain a second comparison result;
[0101] If the first comparison result indicates that the first target position is consistent with the first actual position and the second comparison result indicates that the second target position is consistent with the second actual position, then the preset position condition in the configuration file is met.
[0102] In one of the embodiments, the configuration file further includes a framework adjustment strategy for the first target branch; the synchronization module 31 is configured to obtain the first target branch in the first version library if the second version library is an empty version library and the configuration is complete;
[0103] The first target branch is migrated based on the branch migration command and the framework adjustment strategy to obtain a second target branch in the second version library.
[0104] In one embodiment, the configuration file further includes incremental information of each file in the first target branch; the synchronization module 31 is used to obtain the first target branch in the first version library if the first target branch of the first version library satisfies that there is a file update and the second target branch of the second version library does not have a file update;
[0105] The first target branch is synchronized based on the second target position in the configuration file, the branch synchronization command, and the incremental information in each file to obtain the second target branch in the second version library.
[0106] Each module in the above cross-version library synchronization device can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0107] In an exemplary embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as shown in FIG. Figure 4 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store configuration files and file information before and after synchronization. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a synchronization method across version libraries is implemented.
[0108] Those skilled in the art will understand that Figure 4 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0109] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0110] Synchronize the first target branch in the first version library according to the configuration file to obtain the second target branch in the second version library;
[0111] By using a cryptographic hash function, first file information of each file included in the first target branch and second file information of each file included in the second target branch are calculated to obtain a first cryptographic hash code of the first file information and a second cryptographic hash code of the second file information respectively corresponding to each file;
[0112] If the first cryptographic hash code is consistent with the second cryptographic hash code, and the position comparison result of each file meets the preset position condition in the configuration file, it is determined that the synchronization of the second version library is successful.
[0113] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0114] Synchronize the first target branch in the first version library according to the configuration file to obtain the second target branch in the second version library;
[0115] By using a cryptographic hash function, first file information of each file included in the first target branch and second file information of each file included in the second target branch are calculated to obtain a first cryptographic hash code of the first file information and a second cryptographic hash code of the second file information respectively corresponding to each file;
[0116] If the first cryptographic hash code is consistent with the second cryptographic hash code, and the position comparison result of each file meets the preset position condition in the configuration file, it is determined that the synchronization of the second version library is successful.
[0117] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:
[0118] Synchronize the first target branch in the first version library according to the configuration file to obtain the second target branch in the second version library;
[0119] By using a cryptographic hash function, first file information of each file included in the first target branch and second file information of each file included in the second target branch are calculated to obtain a first cryptographic hash code of the first file information and a second cryptographic hash code of the second file information respectively corresponding to each file;
[0120] If the first cryptographic hash code is consistent with the second cryptographic hash code, and the position comparison result of each file meets the preset position condition in the configuration file, it is determined that the synchronization of the second version library is successful.
[0121] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0122] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0123] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A cross-version library synchronization method, characterized in that: The method comprises: Synchronize the first target branch in the first version library according to the configuration file to obtain the second target branch in the second version library; By using a cryptographic hash function, first file information of each file included in the first target branch and second file information of each file included in the second target branch are calculated to obtain a first cryptographic hash code of the first file information and a second cryptographic hash code of the second file information respectively corresponding to each file; If the first cryptographic hash code is consistent with the second cryptographic hash code, and the position comparison result of each file meets the preset position condition in the configuration file, it is determined that the synchronization of the second version library is successful.
2. The method according to claim 1, characterized in that The first file information includes the branch name, file name and capacity information of each file in the first target branch, and the second file information includes the branch name, file name and capacity information of each file in the second target branch.
3. The method according to claim 2, characterized in that The method of calculating the first file information of each file contained in the first target branch and the second file information of each file contained in the second target branch by using a cryptographic hash function to obtain a first cryptographic hash code of the first file information and a second cryptographic hash code of the second file information respectively corresponding to each file includes: Based on a cryptographic hash function, the branch name, the file name, and the capacity information of each file in the first target branch are calculated to obtain the first cryptographic hash code corresponding to each file; Based on the cryptographic hash function, the branch name, the file name and the capacity information of each file in the second target branch are calculated to obtain the second cryptographic hash code corresponding to each file.
4. The method according to claim 1, characterized in that: The configuration file includes a first target location of each file in the first target branch in the first version library and a second target location of each file in the second target branch in the second version library; The step of determining whether the position comparison result of each file meets the preset position condition in the configuration file includes: Obtaining a first actual location of each file in the first target branch in the first version repository and a second actual location of each file in the second target branch in the second version repository; Comparing the first target position with the first actual position to obtain a first comparison result; comparing the second target position with the second actual position to obtain a second comparison result; If the first comparison result indicates that the first target position is consistent with the first actual position and the second comparison result indicates that the second target position is consistent with the second actual position, then the preset position condition in the configuration file is met.
5. The method according to claim 1, characterized in that The configuration file also includes a framework adjustment strategy for the first target branch; The step of synchronizing the first target branch in the first version repository according to the configuration file to obtain the second target branch in the second version repository includes: If the second version library is an empty version library and the configuration is complete, obtain the first target branch in the first version library; The first target branch is migrated based on the branch migration command and the framework adjustment strategy to obtain a second target branch in the second version library.
6. The method according to claim 4, characterized in that The configuration file also includes incremental information of each file in the first target branch; The step of synchronizing the first target branch in the first version repository according to the configuration file to obtain the second target branch in the second version repository includes: If the first target branch of the first version library satisfies that there is a file update and the second target branch of the second version library does not have a file update, obtain the first target branch in the first version library; The first target branch is synchronized based on the second target position in the configuration file, the branch synchronization command, and the incremental information in each file to obtain the second target branch in the second version library.
7. A cross-version library synchronization device, characterized in that: The device comprises: A synchronization module, used to synchronize the first target branch in the first version library according to the configuration file to obtain the second target branch in the second version library; a calculation module, configured to calculate, by a cryptographic hash function, first file information of each file contained in the first target branch and second file information of each file contained in the second target branch, respectively, to obtain a first cryptographic hash code of the first file information and a second cryptographic hash code of the second file information respectively corresponding to each file; The determination module is configured to determine that the synchronization of the second version library is successful if the first cryptographic hash code is consistent with the second cryptographic hash code and the position comparison result of each file satisfies a preset position condition in the configuration file.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
