Code synchronization method, apparatus, device, and storage medium
By automatically identifying and merging code patches and outputting conflict warning data after receiving upstream code commit notifications, the problem of low code synchronization efficiency and conflict accumulation in existing technologies is solved, achieving efficient and accurate code synchronization and conflict-free main code branch updates.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-20
- Publication Date
- 2026-03-31
AI Technical Summary
Existing technologies suffer from low code synchronization efficiency, inaccurate synchronization, and code conflicts that affect the deployment of application software.
By responding to code commit notifications from the upstream code repository, the downstream code repository is identified. Based on the upstream and downstream code branches, upstream code patches are determined. The main code branch is copied as a synchronization branch, and conflict warning data is output during the merge process to pause the merge until the conflict is resolved. Finally, the downstream main code branch is updated.
It achieves efficient and accurate code synchronization, avoids the accumulation of code conflicts, and ensures that no time is spent resolving conflicts before the application software goes live.
Smart Images

Figure CN116932648B_ABST
Abstract
Description
Technical Field
[0001] This application relates to computer technology, and more particularly to a code synchronization method, apparatus, device, and storage medium. Background Technology
[0002] In the development of computer application software, if the software code references code from the upstream community, then the application software code not only needs to synchronize with the development code, but also with the code referenced from the upstream community.
[0003] Currently, the main method involves staff monitoring the upstream community and developers for code submissions in real time, and then manually merging the upstream community code and development code into the application software code. This method is not only time-consuming and labor-intensive, requiring staff to constantly monitor the upstream community and developers for code submissions, but it is also prone to errors in code merging, missed code synchronization, and other issues. Furthermore, if code conflicts between the application software code and the community / development code are not resolved promptly during the manual merging process, a significant amount of time will be spent resolving these conflicts before the application software is released, impacting its launch.
[0004] In summary, existing code synchronization methods suffer from low synchronization efficiency, inaccurate synchronization, and the accumulation of code conflicts, which hinders the deployment of application software. Summary of the Invention
[0005] This application provides a code synchronization method, apparatus, device, and storage medium to solve the problems of low code synchronization efficiency, untimely synchronization, and inaccurate synchronization in the prior art.
[0006] According to a first aspect of this application, a code synchronization method is provided, comprising:
[0007] In response to receiving a code commit notification from an upstream code repository, determine the downstream code repository that references code in the upstream code repository;
[0008] At least one upstream code patch is determined based on the current upstream code branch included in the upstream code repository and the historical upstream code branch included in the downstream code repository;
[0009] The main code branch included in the downstream code repository is copied, and the copied main code branch is identified as the code synchronization branch.
[0010] Each upstream code patch is merged into the code synchronization branch. During the merging process, in response to any conflict between an upstream code patch and the code synchronization branch, conflict warning data is output, and the merging is paused until the conflict is resolved. The conflict warning data is used to instruct staff to resolve the conflict.
[0011] In response to the merging of all upstream code patches into the code synchronization branch, the main code branch of the downstream code repository is updated according to the code synchronization branch.
[0012] According to a second aspect of this application, a code synchronization device is provided, comprising:
[0013] The first determination module is used to determine the downstream code repository that references code in the upstream code repository in response to receiving a code commit notification from the upstream code repository.
[0014] The second determining module is used to determine at least one upstream code patch based on the current upstream code branch included in the upstream code repository and the historical upstream code branch included in the downstream code repository;
[0015] The copying module is used to copy the main code branch included in the downstream code repository, and to determine the copied main code branch as the code synchronization branch;
[0016] The first merging module is used to merge each upstream code patch into the code synchronization branch. During the merging process, in response to any conflict between any upstream code patch and the code synchronization branch, conflict prompt data is output, and the merging is paused until the conflict is resolved. The conflict prompt data is used to instruct staff to resolve the conflict.
[0017] The second merging module is used to update the main code branch of the downstream code repository in response to the fact that all upstream code patches have been merged into the code synchronization branch.
[0018] According to a third aspect of this application, an electronic device is provided, comprising: a memory, a processor, and a transceiver;
[0019] The memory, the processor, and the transceiver circuitry are interconnected.
[0020] The memory stores computer-executed instructions;
[0021] The transceiver is used to send and receive data;
[0022] The processor executes computer execution instructions stored in the memory to implement the method as described in the first aspect.
[0023] According to a fourth aspect of this application, a computer-readable storage medium is provided, wherein computer-executable instructions are stored therein, which, when executed by a processor, are used to implement the method as described in the first aspect.
[0024] According to a fifth aspect of this application, a computer program product is provided, comprising a computer program that, when executed by a processor, implements the method described in the first aspect.
[0025] The code synchronization method, apparatus, device, and storage medium provided in this application, in response to receiving a code commit notification from an upstream code repository, determine a downstream code repository that references code in the upstream code repository; determine at least one upstream code patch based on the current upstream code branch included in the upstream code repository and the historical upstream code branches included in the downstream code repository; copy the main code branch included in the downstream code repository and determine the copied main code branch as the code synchronization branch; merge each upstream code patch into the code synchronization branch, and during the merging process, in response to any conflict between any upstream code patch and the code synchronization branch, output conflict prompt data and pause the merging until the conflict is resolved; the conflict prompt data is used to instruct staff to resolve the conflict; in response to all upstream code patches being merged into the code synchronization branch, update the main code branch of the downstream code repository according to the code synchronization branch. Because at least one upstream code patch is efficiently and accurately determined based on the upstream code branches included in the upstream code repository and the historical upstream branches of the downstream code repository after receiving the code commit notification from the upstream code repository. Furthermore, during the process of merging upstream code patches into the synchronized code branch, if a conflict arises between the upstream code patch and the synchronized code branch, a conflict warning is output and the merging process is paused until the conflict is resolved. This prevents code conflicts from being left behind or piling up between the upstream code and the synchronized code branch. Also, since the synchronized code branch is copied from the main code branch, after merging all upstream code patches into the synchronized code branch, the synchronized code branch can be merged into the main code branch, resulting in a main code branch free of code conflicts. This allows the application software to avoid spending time resolving code conflicts before deployment. Attached Figure Description
[0026] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0027] Figure 1 This is a network architecture diagram corresponding to the application scenario of the code synchronization method provided in the embodiments of this application;
[0028] Figure 2 This is a flowchart illustrating the code synchronization method provided in Embodiment 1 of this application;
[0029] Figure 3 This is a flowchart illustrating the code synchronization method provided in Embodiment 2 of this application;
[0030] Figure 4 This is a schematic diagram of the code synchronization device provided according to Embodiment 3 of this application;
[0031] Figure 5 This is a schematic diagram of the structure of an electronic device provided according to Embodiment 4 of this application.
[0032] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation
[0033] The terms "first," "second," "third," etc., used in the specification, claims, and drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the invention described herein can be implemented, for example, in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0034] First, the terms used in this application will be explained.
[0035] A code repository is a place where code is stored.
[0036] A code branch is a different piece of code within the same code repository.
[0037] The prior art involved in this application will be described in detail and analyzed below.
[0038] In computer software development, an application is typically developed collaboratively by multiple developers. This requires synchronizing the code submissions from different developers to the main code branch. Additionally, if the application references upstream code from the community, it's necessary to track the upstream community and synchronize any new upstream code submissions to the main code branch. Currently, this is primarily done by staff tracking code submissions from the upstream community in real-time. Once a new submission appears, the new upstream code is manually merged into the main code branch. This method is not only time-consuming and labor-intensive but also prone to errors or omissions, leading to problems with the upstream code referenced in the application. Furthermore, during the synchronization process, conflicts may arise between upstream code submissions and the main code branch. Often, non-conflicting upstream code is merged into the main code branch first, while conflicting upstream code is postponed until the developers resolve the conflicts before synchronization. Therefore, as the application develops, code conflicts between the upstream code and the main code branch can accumulate, requiring significant time to resolve before the application goes live, thus impacting its release.
[0039] In summary, existing code synchronization methods suffer from low synchronization efficiency, inaccurate synchronization, and the accumulation of code conflicts, which hinders the deployment of application software.
[0040] In response to the problems in existing technologies, the inventors, through creative research, have proposed an approach to improve the efficiency and accuracy of code synchronization. This approach involves triggering automatic synchronization of upstream code branches via code commit notifications from the upstream code repository. Furthermore, to avoid spending excessive time resolving code conflicts before application software goes live, conflicts can be resolved during the synchronization process, preventing conflict accumulation. Therefore, the inventors propose the following technical solution: Upon receiving a code commit notification from the upstream code repository, the inventors determine the downstream code repository that references code from the upstream code repository; based on the current upstream code branch in the upstream code repository and the historical upstream code branches in the downstream code repository, they determine at least one upstream code patch; they copy the main code branch in the downstream code repository and designate the copied main code branch as the code synchronization branch; they merge all upstream code patches into the code synchronization branch; and during the merging process, in response to any conflict between an upstream code patch and the code synchronization branch, they output conflict warning data and pause the merging process until the conflict is resolved; the conflict warning data is used to instruct staff to resolve the conflict; and in response to all upstream code patches being merged into the code synchronization branch, they update the main code branch of the downstream code repository according to the code synchronization branch. Upon receiving a code commit notification from the upstream code repository, at least one upstream code patch is efficiently and accurately identified based on the upstream code branches included in the upstream code repository and the historical upstream branches of the downstream code repository. Furthermore, during the merging of upstream code patches into the synchronized code branch, if a conflict exists between the upstream code patch and the synchronized code branch, a conflict warning is output and the merging process is paused until the conflict is resolved. Therefore, no code conflicts are left behind or accumulated between the upstream code and the synchronized code branch. Additionally, since the synchronized code branch is copied from the main code branch, after merging all upstream code patches into the synchronized code branch, the synchronized code branch can be merged into the main code branch to obtain a main code branch free of code conflicts. This allows the application software to proceed without spending time resolving code conflicts before deployment.
[0041] The code synchronization method, apparatus, device, and storage medium provided in this application aim to solve the above-mentioned technical problems of the prior art. The technical solutions of this application and how they solve the aforementioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.
[0042] The network architecture and application scenarios of the code synchronization method provided in the embodiments of this application will be described below. When the following description refers to the accompanying drawings, unless otherwise indicated, the same data in different drawings represent the same or similar elements.
[0043] Figure 1 This is a network architecture diagram corresponding to the application scenario of the code synchronization method provided in the embodiments of this application. For example... Figure 1 As shown in the figure, the network architecture corresponding to an application scenario provided in this application embodiment includes: electronic device 10, upstream code repository 11, and downstream code repository 12.
[0044] The upstream code in the upstream community is stored in the upstream code repository 11. If there is a new code submission in the upstream code repository 11, that is, if the code in the upstream code repository is updated, then the upstream code repository 11 can send a code submission notification to the electronic device 10.
[0045] In response to receiving a code commit notification from an upstream code repository 11, the electronic device 10 identifies a downstream code repository 12 that references code in the upstream code repository 11. The number of downstream code repositories 12 is at least one.
[0046] Electronic device 10 determines at least one upstream code patch based on the current upstream code branch included in upstream code repository 11 and the historical upstream code branch included in downstream code repository 12; it copies the main code branch included in downstream code repository 12 and determines the copied main code branch as the code synchronization branch; it merges each upstream code patch into the code synchronization branch, and during the merging process, in response to any conflict between any upstream code patch and the code synchronization branch, it outputs conflict prompt data and pauses the merging until the conflict is resolved; the conflict prompt data is used to instruct staff to resolve the conflict.
[0047] In response to the merging of all upstream code patches into the code synchronization branch, electronic device 10 updates the main code branch of downstream code repository 12 according to the code synchronization branch.
[0048] The embodiments of this application will now be described with reference to the accompanying drawings. The embodiments described below do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0049] Example 1
[0050] Figure 2 This is a flowchart illustrating the code synchronization method provided in Embodiment 1 of this application. Figure 2 As shown, the executing entity of this application is a code synchronization device, which is located in an electronic device. The code synchronization method provided in this embodiment includes steps 201 to 205.
[0051] Step 201: In response to receiving a code commit notification from the upstream code repository, determine the downstream code repository that references the code in the upstream code repository.
[0052] In this embodiment, a mapping relationship between upstream code repository identifiers and preset code repository identifiers can be pre-established. The upstream code repository identifier can be the Uniform Resource Locator (URL) of the upstream code repository, and the preset code repository identifier can be the URL of the preset code repository. Here, since the code in an upstream code repository can be referenced by multiple other code repositories, the upstream code repository identifier can have a mapping relationship with multiple preset code repository identifiers.
[0053] In this embodiment, code submission notifications can be sent to the electronic device via an HTTP POST request. Therefore, the HTTP POST request can include the URL of the upstream code repository. The electronic device can determine a preset code repository that has a mapping relationship with the URL included in the code submission notification as the downstream code repository that references the code in the upstream code repository. Here, HTTP stands for HyperText Transfer Protocol.
[0054] Step 202: Determine at least one upstream code patch based on the current upstream code branch included in the upstream code repository and the historical upstream code branch included in the downstream code repository.
[0055] In this embodiment, the electronic device can communicate with an upstream code repository and download the current upstream code branch from it. Furthermore, the electronic device can also communicate with a downstream code repository and download its included historical upstream code branches. Historical upstream code branches are the code from the upstream code repository currently referenced by the downstream code repository.
[0056] In this embodiment, the electronic device can compare the current upstream code branch with the historical upstream code branches to determine the similarities and differences between them. Based on these differences, it can determine at least one upstream code patch. The upstream code patch reflects the updates made by the current upstream code branch based on the historical upstream code branches.
[0057] Step 203: Copy the main code branch included in the downstream code repository, and determine the copied main code branch as the code synchronization branch.
[0058] In this embodiment, the code synchronization branch is copied from the main code branch and is completely identical to it. The electronic device can communicate with the downstream code repository, copy the main code branch from the downstream code repository, and designate the copied main code branch as the code synchronization branch. The code synchronization branch can be used to synchronize the code in the downstream code repository with the upstream code repository.
[0059] Step 204: Merge each upstream code patch into the code synchronization branch. During the merging process, if any upstream code patch conflicts with the code synchronization branch, output conflict warning data and pause the merging until the conflict is resolved. The conflict warning data is used to instruct staff to resolve the conflict.
[0060] In this embodiment, since the upstream code patch can reflect the update of the current upstream code based on the historical upstream code, and the code synchronization branch is obtained by copying the main code branch, if all the upstream code patches can be merged into the code synchronization branch, then all the upstream code patches may be merged into the main code branch, thereby realizing the synchronization of the code in the downstream code repository with the code in the upstream code repository.
[0061] In this embodiment, a synchronization function can be pre-built in the electronic device. This function can be used to traverse each upstream code patch. Upon encountering a new upstream code patch, the currently traversed patch is merged into the code synchronization branch. If a code conflict occurs between the currently traversed upstream code patch and the code synchronization branch, the synchronization function can output conflict warning data and pause the traversal of each upstream code patch until the conflict is resolved. If there is no code conflict between the currently traversed upstream code patch and the code synchronization branch, the currently traversed upstream code patch can be successfully merged into the code synchronization branch, and the synchronization function can traverse to the next upstream code patch until all upstream code patches have been traversed and merged into the code synchronization distribution.
[0062] Step 205: In response to the fact that all upstream code patches have been merged into the code synchronization branch, update the main code branch of the downstream code repository according to the code synchronization branch.
[0063] In this embodiment, if all upstream code patches are merged into the code synchronization branch, it means that all code conflicts between the upstream code patches and the code synchronization branch have been resolved, and the current upstream code branch has been successfully merged into the code synchronization branch. Since the synchronization branch is copied from the upstream code branch, updating the main code branch of the downstream code repository according to the code synchronization branch can complete the synchronization of the code in the upstream code repository referenced by the downstream code repository.
[0064] In this embodiment, the code synchronization branch and the main code branch can be compared to determine the differences between them. The differences between the code synchronization branch and the main code branch can then be modified accordingly in the main code branch to make the main code branch the same as the code synchronization branch, thus completing the update of the main code branch.
[0065] The code synchronization method provided in this embodiment determines the downstream code repository that references code in the upstream code repository in response to receiving a code commit notification from the upstream code repository; determines at least one upstream code patch based on the current upstream code branch included in the upstream code repository and the historical upstream code branches included in the downstream code repository; copies the main code branch included in the downstream code repository and determines the copied main code branch as the code synchronization branch; merges each upstream code patch into the code synchronization branch, and during the merging process, in response to any conflict between any upstream code patch and the code synchronization branch, outputs conflict prompt data and pauses the merging until the conflict is resolved; the conflict prompt data is used to instruct staff to resolve the conflict; in response to all upstream code patches being merged into the code synchronization branch, updates the main code branch of the downstream code repository according to the code synchronization branch. Because at least one upstream code patch is efficiently and accurately determined based on the upstream code branches included in the upstream code repository and the historical upstream branches of the downstream code repository after receiving the code commit notification from the upstream code repository. Furthermore, during the process of merging upstream code patches into the synchronized code branch, if a conflict arises between the upstream code patch and the synchronized code branch, a conflict warning is output and the merging process is paused until the conflict is resolved. This prevents code conflicts from being left behind or piling up between the upstream code and the synchronized code branch. Also, since the synchronized code branch is copied from the main code branch, after merging all upstream code patches into the synchronized code branch, the synchronized code branch can be merged into the main code branch, resulting in a main code branch free of code conflicts. This allows the application software to avoid spending time resolving code conflicts before deployment.
[0066] Optionally, step 204, "in response to a conflict between any upstream code patch and the code synchronization branch, output conflict warning data", is further refined to include steps 301 to 303.
[0067] Step 301: In response to a conflict between any upstream code patch and the code synchronization branch, obtain the first conflicting code in the code synchronization branch that conflicts with the upstream code patch.
[0068] In this embodiment, for any upstream code patch, if the upstream code patch conflicts with the code synchronization branch, the electronic device can identify the code in the code synchronization branch that conflicts with the upstream code patch as the first conflicting code.
[0069] Step 302: Obtain the connection address of the upstream code repository.
[0070] In this embodiment, the connection address of the upstream code repository can be the Uniform Resource Locator (URL) of the upstream code repository.
[0071] Step 303: Output the upstream code patch that conflicts with the code synchronization branch, the first conflicting code, and the connection address as conflict warning data in the preset communication software.
[0072] In this embodiment, the preset communication software can be pre-configured on the terminal device of the developer or relevant staff so that after the conflict prompt data is output, the developer or relevant staff can receive the conflict prompt data as soon as possible and resolve the conflict in a timely manner.
[0073] In this embodiment, the conflict alert data includes: the upstream code patch that conflicts with the code synchronization branch, the first conflicting code, and the connection address of the upstream code repository corresponding to the upstream code patch.
[0074] The code synchronization method provided in this embodiment, in response to a conflict between any upstream code patch and the code synchronization branch, obtains the first conflicting code in the code synchronization branch that conflicts with the upstream code patch; obtains the connection address of the upstream code repository; and outputs the upstream code patch that conflicts with the code synchronization branch, the first conflicting code, and the connection address as conflict alert data in a preset communication software. Since the connection address reflects the source of the upstream code patch, and the upstream code patch and the first conflicting code directly reflect the conflicting code, it facilitates quick location and resolution of conflicts after receiving the conflict alert data, thus improving code synchronization efficiency.
[0075] Optionally, step 205, "in response to all upstream code patches being merged into the code synchronization branch, update the main code branch of the downstream code repository according to the code synchronization branch," is further refined to include steps 401 to 405.
[0076] Step 401: In response to the fact that all upstream code patches have been merged into the code synchronization branch, determine whether the historical development code branches included in the downstream code repository are the same as the current development code branch.
[0077] In this embodiment, the current development code branch is the latest development code in the downstream code repository, and the historical development code branch is the development code currently referenced in the downstream code repository. In other words, the historical code branch is the development code that has been merged into the main code branch of the downstream code repository.
[0078] In this embodiment, if all upstream code patches are merged into the code synchronization branch, it means that all code conflicts between the upstream code patches and the code synchronization branch have been resolved. At this time, the electronic device can download the historical development code and the current development code included in the downstream code repository, and can determine whether the development code has been updated by comparing the current development code and the historical development code.
[0079] Step 402: In response to the fact that the historical development code branch is the same as the current development code branch, update the main code branch of the downstream code repository according to the code synchronization branch.
[0080] In this embodiment, if the current development code is the same as the historical development code, it means that the current development code has not been updated. The main code in the downstream code repository does not need to synchronize the development code; it only needs to synchronize the upstream code. Therefore, the electronic device can update the main code branch of the downstream code repository according to the code synchronization branch, thus completing the synchronization of the main code branch in the downstream code repository with the upstream code repository.
[0081] Step 403: In response to the difference between the historical development code branch and the current development code branch, identify at least one development code patch.
[0082] In this embodiment, if the current development code differs from the historical development code, it indicates that the development code has been updated. The main code in the downstream code repository needs to synchronize not only with the upstream code but also with the development code. However, the new development code may conflict with the synchronized branch. Therefore, to complete the synchronization of the downstream code repository with the upstream code and the development code, and to avoid the accumulation of code conflicts, it is necessary to promptly resolve any potential conflicts between the development code and the main code branch or the current upstream code branch.
[0083] In this embodiment, the electronic device can compare the current development code with the historical development code to determine the differences between the two, and then determine a development code patch based on these differences. For example, the differences between the previous and historical development code can be used as development code patches. Since the current development code differs from the historical development code, there is at least one development code patch.
[0084] Step 404: Merge each development code patch into the code synchronization branch. During the merging process, if any development code patch conflicts with the code synchronization branch, output conflict warning data and pause the merging until the conflict is resolved. The conflict warning data is used to instruct staff to resolve the conflict.
[0085] In this embodiment, each development code patch can be merged into the code synchronization branch in the same way as in step 204, where each upstream code patch is merged into the code synchronization branch. This will not be elaborated here.
[0086] Step 405: In response to the fact that all development code patches have been merged into the code synchronization branch, update the main code branch of the downstream code repository according to the code synchronization branch.
[0087] In this embodiment, if all development code is merged into the code synchronization branch, it means that all code conflicts between the development code patches and the code synchronization branch have been resolved, and both the current upstream code branch and the current development code branch have been successfully merged into the code synchronization branch. Therefore, by updating the main code branch of the downstream code repository according to the code synchronization branch, the downstream code repository can synchronize the code in the upstream code repository it references, as well as the development code.
[0088] The code synchronization method provided in this embodiment determines whether the historical development code branch and the current development code branch included in the downstream code repository are the same in response to all upstream code patches being merged into the code synchronization branch; in response to the historical development code branch being the same as the current development code branch, the main code branch of the downstream code repository is updated according to the code synchronization branch; in response to the historical development code branch being different from the current development code branch, at least one development code patch is identified; all development code patches are merged into the code synchronization branch, and during the merging process, in response to any conflict between any development code patch and the code synchronization branch, conflict prompt data is output, and the merging is paused until the conflict is resolved; the conflict prompt data is used to instruct staff to resolve the conflict; in response to all development code patches being merged into the code synchronization branch, the main code branch of the downstream code repository is updated according to the code synchronization branch. Because during the process of merging development patches into the code synchronization branch, if a code conflict occurs, a conflict warning is output and the merging process is paused until the conflict is resolved, all code conflicts between the current development code, the code synchronization branch, and the current upstream code branch have been resolved. There will be no residual or accumulated code conflicts. If the application software needs to be deployed, there is no need to resolve code conflicts again. It is only necessary to update the main code branch of the downstream code repository according to the code synchronization branch, and this update process will not involve code conflicts.
[0089] Optionally, step 404, "in response to a conflict between any development code patch and the code synchronization branch, output conflict warning data", can be further refined to include steps 501 to 504.
[0090] Step 501: In response to a conflict between any development code patch and the code synchronization branch, obtain the second conflicting code in the code synchronization branch that conflicts with the development code patch.
[0091] In this embodiment, for any development code patch, if the development code patch conflicts with the code synchronization branch, then the conflict can be in the following two situations.
[0092] In the first scenario, the conflict is between the development code patch and the code synchronization branch that has not been merged with the upstream patch code. Essentially, it is a conflict between the development code patch and the main code, a conflict between the current development code and the main code.
[0093] The second scenario involves a conflict between the development code patch and a synchronized branch that has already merged all upstream patch code. Essentially, it's a conflict between the current development code and the upstream patch code, or between the current development code and the current upstream code. Therefore, to facilitate further determination of the conflict's source, the electronic device can retrieve the second conflicting code from the synchronized branch that conflicts with the current development code.
[0094] Step 502: Determine whether the second conflicting code was obtained by merging upstream code patches.
[0095] In this embodiment, if the second conflicting code is code obtained before the code synchronization branch merges all upstream code patches, then the second conflicting code is not obtained by merging upstream code patches. If the second conflicting code includes code from any one of the upstream code patches, or if the second conflicting code is code obtained after the code synchronization branch merges any one of the upstream patch codes, then the second conflicting code is obtained by merging upstream patch code.
[0096] Step 503: In response to the fact that the second conflict code is obtained by merging the upstream code patch, obtain the connection address of the upstream code repository, and output the development code patch that conflicts with the code synchronization branch, the second conflict code, and the connection address as conflict prompt data in the preset communication software.
[0097] In this embodiment, if the second conflicting code is obtained by merging the upstream code patch, it means that the conflict between the development code patch and the code synchronization branch is a conflict between the current development code branch and the current upstream code branch. Therefore, the conflict prompt data needs to include: the development code patch that conflicts with the code synchronization branch, the connection address of the upstream code repository of the second conflicting code, and the connection address of the upstream code repository, so that the staff who resolve the conflict can quickly locate and resolve the conflict after receiving the conflict prompt data, thereby improving the code synchronization efficiency.
[0098] Step 504: In response to the fact that the second conflicting code was not obtained by merging the upstream code patch, the development code patch that conflicts with the code synchronization branch and the second conflicting code are output as conflict warning data in the preset communication software.
[0099] In this embodiment, if the second conflicting code is not obtained by merging the upstream code patch, it means that the conflict between the development code patch and the code synchronization branch is a conflict between the current development code branch and the main code branch. Therefore, the conflict warning data needs to include: the development code patch that conflicts with the code synchronization branch and the second conflicting code, so that the staff who resolve the conflict can quickly locate and resolve the conflict after receiving the conflict warning data, thereby improving the efficiency of code synchronization.
[0100] The code synchronization method provided in this embodiment, in response to a conflict between any development code patch and the code synchronization branch, obtains the second conflicting code in the code synchronization branch that conflicts with the development code patch; determines whether the second conflicting code was obtained by merging an upstream code patch; if the second conflicting code was obtained by merging an upstream code patch, obtains the connection address of the upstream code repository, and outputs the development code patch that conflicts with the code synchronization branch, the second conflicting code, and the connection address as conflict warning data in a preset communication software; if the second conflicting code was not obtained by merging an upstream code patch, both the development code patch that conflicts with the code synchronization branch and the second conflicting code are output as conflict warning data in the preset communication software. Since the conflict warning data includes the specific conflicting code, after the conflict warning data is output, staff can quickly locate and resolve conflicts based on the conflict warning data, improving code synchronization efficiency.
[0101] Optionally, step 205, "in response to all upstream code patches being merged into the code synchronization branch, update the main code branch of the downstream code repository according to the code synchronization branch," is further refined to include steps 601 to 602.
[0102] Step 601: In response to the fact that all upstream code patches have been merged into the code synchronization branch, an upstream code merging completion message is output through the preset communication software.
[0103] In this embodiment, if all upstream code patches are merged into the synchronized code branch, it indicates that all code conflicts between the current upstream code branch and the synchronized code branch have been resolved. Therefore, the synchronized code branch can be quickly merged into the main code branch. Here, since the downstream code repository has only one main branch, and the official version of the application software provided to users is released on the main code branch, whether to merge the synchronized code branch into the main code branch needs to be decided by the staff. The electronic device can output an upstream code merge completion message through preset communication software to prompt the staff to merge the synchronized code branch into the main code branch.
[0104] Step 602: In response to receiving the code synchronization instruction triggered by the staff, update the main code branch of the downstream code repository according to the code synchronization branch.
[0105] In this embodiment, staff can trigger a code synchronization command in an electronic device. After receiving the code synchronization command, the electronic device can quickly update the main code branch of the downstream code repository according to the code synchronization branch.
[0106] The code synchronization method provided in this embodiment, in response to the merging of all upstream code patches into the code synchronization branch, outputs an upstream code merging completion message through a preset communication software; in response to receiving a code synchronization command triggered by a worker, it updates the main code branch of the downstream code repository according to the code synchronization branch. Since the electronic device only updates the main code branch of the downstream code repository after receiving the code synchronization command, the worker can flexibly choose the update time for the main code branch.
[0107] Optionally, step 405, "in response to all development code patches being merged into the code synchronization branch, the main code branch of the downstream code repository is updated according to the code synchronization branch," is further refined to include steps 701 to 702.
[0108] Step 701: In response to the fact that all development code patches have been merged into the code synchronization branch, a development code merging completion message is output through the preset communication software.
[0109] In this embodiment, if all development code patches are merged into the code synchronization branch, it indicates that all code conflicts between the current development code branch and the code synchronization branch have been resolved. Therefore, the code synchronization branch can be quickly merged into the main code branch. Similarly to step 601, the electronic device can output a development code merging completion message through preset communication software to prompt the staff to merge the code synchronization branch into the main code branch.
[0110] Step 702: In response to receiving the code synchronization instruction triggered by the staff, update the main code branch of the downstream code repository according to the code synchronization branch.
[0111] In this embodiment, staff can trigger a code synchronization command in an electronic device. After receiving the code synchronization command, the electronic device can quickly update the main code branch of the downstream code repository according to the code synchronization branch.
[0112] The code synchronization method provided in this embodiment, in response to all development code patches being merged into the code synchronization branch, outputs a development code merging completion message through a preset communication software; in response to receiving a code synchronization command triggered by a worker, it updates the main code branch of the downstream code repository according to the code synchronization branch. Since the electronic device only updates the main code branch of the downstream code repository after receiving the code synchronization command, workers can flexibly choose the update time for the main code branch.
[0113] Optionally, step 205, "update the main code branch of the downstream code repository according to the code synchronization branch", can be further refined to include steps 801 to 802.
[0114] Step 801: Update the historical upstream code branch using the current upstream code branch.
[0115] In this embodiment, the electronic device can merge the current upstream code branch into the historical upstream code branch, thereby updating the historical upstream code branch. Specifically, the electronic device can copy the current upstream code branch and designate the copied current upstream code branch as the new historical upstream code branch.
[0116] Step 802: Update the historical development code branch using the current development code branch.
[0117] In this embodiment, the electronic device can merge the current development code branch into a historical development code branch, thereby updating the historical development code branch. Specifically, the electronic device can copy the current development code branch and designate the copied current development code branch as the new historical development code branch.
[0118] The code synchronization method provided in this embodiment updates historical upstream code branches using the current upstream code branch, and updates historical development code branches using the current development code branch. Since the historical upstream code branches in the downstream code repository are updated to the current upstream code branch, and the historical development code branches are updated to the current development code branch, it ensures that the upstream code and development code in the downstream code repository are up-to-date. This reduces the workload of synchronizing the upstream and development code when they are updated again.
[0119] Example 2
[0120] Figure 3 This is a flowchart illustrating the code synchronization method provided in Embodiment 2 of this application. Figure 3 As shown, the code synchronization method provided in this embodiment includes steps 901 to 911.
[0121] Step 901: In response to receiving a code commit notification from the upstream code repository, determine the downstream code repository that references the code in the upstream code repository.
[0122] In this embodiment, an automatic synchronization task can be built on a preset continuous integration tool. The automatic synchronization task can have preset triggering conditions. These preset triggering conditions can be configured through preset task triggers. Specifically, the automatic synchronization task is used to synchronize downstream code repositories. The preset continuous integration tool can be Jenkins, the preset task trigger can be a Generic Webhook Trigger, and the preset triggering condition can be a Uniform Resource Locator (URL) of the upstream code repository.
[0123] In this embodiment, the upstream code repository is configured so that when the code in the upstream code repository is updated, the upstream code repository pushes a code commit notification to the electronic device. The code commit notification includes the Uniform Resource Locator (URL) of the upstream code repository. After receiving the upstream code commit notification, the electronic device can trigger an automatic synchronization task using the URL of the upstream code repository, thereby achieving automatic synchronization with the downstream code repository.
[0124] Step 902: Determine at least one upstream code patch based on the current upstream code branch included in the upstream code repository and the historical upstream code branch included in the downstream code repository.
[0125] Step 903: Copy the main code branch included in the downstream code repository, and determine the copied main code branch as the code synchronization branch.
[0126] Step 904: Merge each upstream code patch into the code synchronization branch. During the merging process, in response to any conflict between an upstream code patch and the code synchronization branch, output conflict warning data and pause the merging process until the conflict is resolved. The conflict warning data is used to instruct staff to resolve the conflict.
[0127] Step 905: In response to the fact that all upstream code patches have been merged into the code synchronization branch, determine whether the historical development code branches included in the downstream code repository are the same as the current development code branch.
[0128] Step 906: In response to the fact that the historical development code branch is the same as the current development code branch, the code synchronization branch is copied, and the copied code synchronization branch is determined as the main code branch after the downstream code repository is updated.
[0129] Step 907: In response to the difference between the historical development code branch and the current development code branch, identify at least one development code patch.
[0130] Step 908: Merge each development code patch into the code synchronization branch. During the merging process, if any development code patch conflicts with the code synchronization branch, output conflict warning data and pause the merging until the conflict is resolved. The conflict warning data is used to instruct staff to resolve the conflict.
[0131] Step 909: In response to the fact that all development code patches have been merged into the code synchronization branch, the code synchronization branch is copied, and the copied code synchronization branch is determined as the main code branch after the downstream code repository is updated.
[0132] Step 910: Update the historical upstream code branch using the current upstream code branch.
[0133] Step 911: Update the historical development code branch using the current development code branch.
[0134] It should be noted that, in Figure 3 The steps shown are not intended to limit the scope of this application. In other embodiments of this application, the code synchronization method includes... Figure 3 More or fewer steps Figure 3 Some steps in the process can be replaced by steps with the same function, or... Figure 3 Some steps in the process can be broken down into multiple steps.
[0135] Example 3
[0136] Figure 4 This is a schematic diagram of the code synchronization device provided according to Embodiment 3 of this application. Figure 4 As shown, the code synchronization device 40 provided in this embodiment includes: a first determining module 41, a second determining module 42, a copying module 43, a first merging module 44, and a second merging module 45.
[0137] The first determining module 41 is used to determine the downstream code repository that references code in the upstream code repository in response to receiving a code commit notification from the upstream code repository.
[0138] The second determining module 42 is used to determine at least one upstream code patch based on the current upstream code branch included in the upstream code repository and the historical upstream code branch included in the downstream code repository.
[0139] The copy module 43 is used to copy the main code branch included in the downstream code repository and identify the copied main code branch as the code synchronization branch.
[0140] The first merging module 44 is used to merge each upstream code patch into the code synchronization branch. During the merging process, in response to any conflict between an upstream code patch and the code synchronization branch, conflict prompt data is output and the merging is paused until the conflict is resolved. The conflict prompt data is used to instruct staff to resolve the conflict.
[0141] The second merging module 45 is used to update the main code branch of the downstream code repository in response to the fact that all upstream code patches have been merged into the code synchronization branch.
[0142] Optionally, the first merging module 44 is specifically used for:
[0143] In response to a conflict between any upstream code patch and the code synchronization branch, retrieve the first conflicting code in the code synchronization branch that conflicts with the upstream code patch.
[0144] Obtain the connection address of the upstream code repository;
[0145] The upstream code patch that conflicts with the code synchronization branch, the first conflicting code, and the connection address are output as conflict warning data in the preset communication software.
[0146] Optionally, the second merging module 45 is specifically used for:
[0147] In response to the fact that all upstream code patches have been merged into the code synchronization branch, determine whether the historical development code branches included in the downstream code repository are the same as the current development code branch;
[0148] In response to the situation where the historical development code branch is the same as the current development code branch, the main code branch of the downstream code repository is updated according to the code synchronization branch;
[0149] In response to differences between historical development code branches and current development code branches, identify at least one development code patch;
[0150] Each development code patch is merged into the code synchronization branch. During the merge process, if any development code patch conflicts with the code synchronization branch, conflict warning data is output and the merge is paused until the conflict is resolved. The conflict warning data is used to instruct staff to resolve the conflict.
[0151] In response to the merging of all development code patches into the code synchronization branch, the main code branch of the downstream code repository is updated according to the code synchronization branch.
[0152] Optionally, the second merging module 45 is further used for:
[0153] In response to a conflict between any development code patch and the code synchronization branch, retrieve the second conflicting code in the code synchronization branch that conflicts with the development code patch.
[0154] Determine whether the second conflicting code was obtained by merging upstream code patches;
[0155] In response to the fact that the second conflict code is obtained by merging the upstream code patch, the connection address of the upstream code repository is obtained, and the development code patch that conflicts with the code synchronization branch, the second conflict code, and the connection address are output as conflict prompt data in the preset communication software.
[0156] In response to the fact that the second conflicting code was not obtained by merging the upstream code patch, the development code patch that conflicts with the code synchronization branch and the second conflicting code are output as conflict warning data in the preset communication software.
[0157] Optionally, the second merging module 45 is further used for:
[0158] In response to the fact that all upstream code patches have been merged into the code synchronization branch, a message indicating that the upstream code merge is complete is output through the preset communication software.
[0159] In response to receiving a code synchronization command triggered by a worker, the main code branch of the downstream code repository is updated according to the code synchronization branch.
[0160] Optionally, the second merging module 45 is further used for:
[0161] In response to the fact that all development code patches have been merged into the code synchronization branch, a development code merging completion message is output through the preset communication software;
[0162] In response to receiving a code synchronization command triggered by a worker, the main code branch of the downstream code repository is updated according to the code synchronization branch.
[0163] Optionally, the second merging module 45 is further used for:
[0164] The code synchronization branch is copied, and the copied code synchronization branch is identified as the main code branch after the downstream code repository is updated.
[0165] Optionally, the code synchronization device 40 also includes an update module, which is used for:
[0166] Update the historical upstream code branch using the current upstream code branch;
[0167] Update historical development code branches using the current development code branch.
[0168] The code synchronization device provided in this embodiment can execute any of the code synchronization methods provided in the above embodiments. The specific implementation and principle are similar, and will not be described again here.
[0169] Example 4
[0170] Figure 5 This is a schematic diagram of the structure of an electronic device according to Embodiment 4 of this application. Figure 5 As shown, the electronic device 50 provided in this embodiment includes: a memory 51, a processor 52, and a transceiver 53.
[0171] The memory 51, processor 52 and transceiver 53 are interconnected.
[0172] Memory 51 stores computer-executed instructions.
[0173] Transceiver 53 is used for sending and receiving data.
[0174] The processor 52 executes the computer execution instructions stored in the memory 51 to implement the code synchronization method provided in any of the above embodiments. The specific implementation method and principle are similar and will not be described again here.
[0175] The memory 51, processor 52, and transceiver 53 can be interconnected via a bus. This bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be categorized into address bus, data bus, control bus, etc. For ease of representation, Figure 5 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0176] Memory can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk, etc.
[0177] In an exemplary embodiment, the electronic device may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the code synchronization method described above.
[0178] Embodiments of this application also provide a computer-readable storage medium storing computer-executable instructions. When executed by a processor, these instructions are used to implement the code synchronization method provided in any of the above embodiments. The specific implementation and principle are similar and will not be repeated here. Exemplarily, the computer-readable storage medium can be a read-only memory (ROM), a random access memory (RAM), magnetic tape, floppy disk, or optical data storage device, etc.
[0179] The embodiments of this application also provide a computer program product, including a computer program that, when executed by a processor, implements the code synchronization method provided in any of the above embodiments. The specific implementation method and principle are similar and will not be described again here.
[0180] It should be understood that the above-described device embodiments are merely illustrative, and the device of this application can also be implemented in other ways. For example, the module division in the above embodiments is only a logical functional division, and there may be other division methods in actual implementation. For example, multiple modules can be combined, or integrated into another system, or some features can be ignored or not executed.
[0181] Furthermore, unless otherwise specified, the functional modules in the various embodiments of this application can be integrated into one module, or each module can exist physically separately, or two or more modules can be integrated together. The integrated modules described above can be implemented in hardware or as software program modules.
[0182] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily essential to this application.
[0183] It should be further noted that although the steps in the flowchart are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowchart may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.
[0184] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.
[0185] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
Claims
1. A code synchronization method, characterized by, The method comprises the following steps: in response to receiving a code commit notification of an upstream code repository, determining a downstream code repository referencing code in the upstream code repository; determining at least one upstream code patch by comparing differences between a current upstream code branch included in the upstream code repository and a historical upstream code branch included in the downstream code repository; copying a master code branch included in the downstream code repository and determining a copied master code branch as a code synchronization branch; the master code branch is a branch in the downstream code repository for publishing official version code; merging each upstream code patch into the code synchronization branch, and in the process of merging, in response to any upstream code patch having a conflict with the code synchronization branch, outputting conflict prompt data and pausing merging until the conflict is resolved; the conflict prompt data is used to instruct a worker to resolve the conflict; in response to each upstream code patch being merged into the code synchronization branch, updating the master code branch of the downstream code repository according to the code synchronization branch; the updating the master code branch of the downstream code repository according to the code synchronization branch comprises copying the code synchronization branch and determining the copied code synchronization branch as the updated master code branch of the downstream code repository; or comparing the code synchronization branch with the master code branch to determine differences between the code synchronization branch and the master code branch, and modifying the differences between the code synchronization branch and the master code branch in the master code branch so that the master code branch is the same as the code synchronization branch. the outputting conflict prompt data in response to any upstream code patch having a conflict with the code synchronization branch comprises:
2. The method of claim 1, wherein, in response to any upstream code patch having a conflict with the code synchronization branch, obtaining first conflict code in the code synchronization branch having a conflict with the upstream code patch; obtaining a connection address of the upstream code repository; outputting the upstream code patch having a conflict with the code synchronization branch, the first conflict code and the connection address as the conflict prompt data in a preset communication software. the updating the master code branch of the downstream code repository according to the code synchronization branch in response to each upstream code patch being merged into the code synchronization branch comprises:
3. The method of claim 1, wherein, in response to each upstream code patch being merged into the code synchronization branch, determining whether a historical development code branch and a current development code branch included in the downstream code repository are the same; in response to the historical development code branch and the current development code branch being the same, updating the master code branch of the downstream code repository according to the code synchronization branch; in response to the historical development code branch and the current development code branch being different, determining at least one development code patch; merge each development code patch into the code synchronization branch, and in the process of merging, in response to any development code patch being in conflict with the code synchronization branch, output conflict prompt data, and pause merging until the conflict is resolved; the conflict prompt data is used to instruct the staff to resolve the conflict; in response to each development code patch being merged into the code synchronization branch, update the main code branch of the downstream code repository according to the code synchronization branch.
4. The method of claim 3, wherein, The response to any development code patch being in conflict with the code synchronization branch includes: in response to any development code patch being in conflict with the code synchronization branch, obtaining second conflict code in the code synchronization branch that is in conflict with the development code patch; determine whether the second conflict code is obtained by merging the upstream code patch; in response to the second conflict code being obtained by merging the upstream code patch, obtaining the connection address of the upstream code repository, and outputting the development code patch in conflict with the code synchronization branch, the second conflict code and the connection address as the conflict prompt data in the preset communication software; in response to the second conflict code not being obtained by merging the upstream code patch, output the development code patch in conflict with the code synchronization branch and the second conflict code as the conflict prompt data in the preset communication software.
5. The method of claim 1, wherein, The response to each upstream code patch being merged into the code synchronization branch includes: in response to each upstream code patch being merged into the code synchronization branch, output an upstream code merging completion message through a preset communication software; in response to receiving a code synchronization instruction triggered by the staff, update the main code branch of the downstream code repository according to the code synchronization branch.
6. The method according to any one of claims 1-5, characterized in that, The response to each development code patch being merged into the code synchronization branch includes: update the historical upstream code branch with the current upstream code branch; update the historical development code branch with the current development code branch.
7. A code synchronization apparatus characterized by comprising: The code synchronization device is used to implement the code synchronization method of any one of claims 1-6, and the device comprises: a first determination module for determining a downstream code repository that references the code in the upstream code repository in response to receiving a code submission notification of the upstream code repository; a second determination module for determining at least one upstream code patch according to a current upstream code branch included in the upstream code repository and a historical upstream code branch included in the downstream code repository; a copying module for copying a main code branch included in the downstream code repository and determining the copied main code branch as a code synchronization branch; a merging module for merging each development code patch into the code synchronization branch, and in the process of merging, in response to any development code patch being in conflict with the code synchronization branch, output conflict prompt data, and pause merging until the conflict is resolved; the conflict prompt data is used to instruct the staff to resolve the conflict; in response to each development code patch being merged into the code synchronization branch, update the main code branch of the downstream code repository according to the code synchronization branch. The response to any development code patch being in conflict with the code synchronization branch includes: in response to any development code patch being in conflict with the code synchronization branch, obtaining second conflict code in the code synchronization branch that is in conflict with the development code patch; determine whether the second conflict code is obtained by merging the upstream code patch; in response to the second conflict code being obtained by merging the upstream code patch, obtaining the connection address of the upstream code repository, and outputting the development code patch in conflict with the code synchronization branch, the second conflict code and the connection address as the conflict prompt data in the preset communication software; in response to the second conflict code not being obtained by merging the upstream code patch, output the development code patch in conflict with the code synchronization branch and the second conflict code as the conflict prompt data in the preset communication software. The response to each upstream code patch being merged into the code synchronization branch includes: in response to each upstream code patch being merged into the code synchronization branch, output an upstream code merging completion message through a preset communication software; in response to receiving a code synchronization instruction triggered by the staff, update the main code branch of the downstream code repository according to the code synchronization branch. The response to each development code patch being merged into the code synchronization branch includes: update the historical upstream code branch with the current upstream code branch; update the historical development code branch with the current development code branch. The code synchronization device is used to implement the code synchronization method of any one of claims 1-6, and the device comprises: a first determination module for determining a downstream code repository that references the code in the upstream code repository in response to receiving a code submission notification of the upstream code repository; a second determination module for determining at least one upstream code patch according to a current upstream code branch included in the upstream code repository and a historical upstream code branch included in the downstream code repository; a copying module for copying a main code branch included in the downstream code repository and determining the copied main code branch as a code synchronization branch; The first merging module is configured to merge each upstream code patch into the code synchronization branch, and in the process of merging, in response to any upstream code patch conflicting with the code synchronization branch, output conflict prompt data and pause merging until the conflict is resolved; the conflict prompt data is used to instruct a worker to resolve the conflict; The second merging module is configured to update the main code branch of the downstream code repository according to the code synchronization branch in response to each upstream code patch being merged into the code synchronization branch.
8. An electronic device, comprising: Comprise: a memory, a processor and a transceiver; the memory, the processor and the transceiver circuit are interconnected; the memory stores computer execution instructions; the transceiver is used for transceiving data; the processor executes the computer execution instructions stored in the memory to realize the method in any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer execution instructions, and the computer execution instructions are executed by the processor to realize the method in any one of claims 1-6.
Citation Information
Patent Citations
Method and system for code management based on distributed collaborative development environment
CN102929630A
Code synchronization method and device, computer readable medium and terminal
CN108228256A