Code merging state detection method and device, equipment, readable storage medium and program product
By synchronously saving remote repository branch code in a distributed version control system and comparing the submitted object collection, detecting whether the branch code is merged into the main line code, solving the problem of merge conflicts and inconsistencies in the code base, and improving development efficiency.
Patent Information
- Application Number
- CN202411462093.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-18
- Publication Date
- 2025-01-14
- Estimated Expiration
- 2044-10-18
AI Technical Summary
During the software development process, branch management and code merging in distributed version control systems become complicated, and merge conflicts and unfinished merge problems are prone to problems, resulting in inconsistent code bases and affecting development efficiency.
By synchronously saving the branch code in the remote repository to the local area, obtain the collection of commit objects on the main line code of the remote repository and the local code, compare the data relationship between the two, and detect whether the branch code is merged into the main line code, and compare it in real time or time. Code changes to reduce the tedious process of manual inspection.
Detect the abnormal merging of branch codes in a timely and accurate manner, avoid inconsistency in the code base, and improve the development efficiency of code development projects.
Smart Images

Figure CN119311312A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer programming technology, and in particular to a code merging status detection method, device, computer equipment, computer readable storage medium and computer program product. Background Art
[0002] In the process of software development, version control system is an important tool for managing code versions and collaborative development. Nowadays, more and more software development teams use distributed version control systems to manage branches, merge and synchronize the code in code development projects for collaborative development. However, with the expansion of the scale of code development projects and the increase in the number of developers, branch management and code merging have become increasingly complex.
[0003] In actual use of distributed version control systems in traditional technologies, the inventors have found that codes on different branches are often prone to merge conflicts, incomplete merges and other problems, and these problems are often difficult to find and deal with in a timely manner, which makes it easy for code bases to be inconsistent, which is not conducive to the normal progress of code development projects. Summary of the invention
[0004] Based on this, it is necessary to provide a code merging status detection method, device, computer equipment, computer-readable storage medium and computer program product that can timely detect abnormal merging problems of branch codes in response to the above technical problems.
[0005] In a first aspect, the present application provides a method for detecting a code merge status, the method comprising:
[0006] Synchronize and save the commit objects of the branch code in the remote repository to the local repository;
[0007] Obtain a first set of commit objects and a second set of commit objects; the first set of commit objects includes commit objects that exist on the mainline code of the remote repository and do not exist on the local; the second set of commit objects includes commit objects that exist on the local and do not exist on the mainline code of the remote repository;
[0008] According to the data relationship between the submission content associated with the first submission object set and the submission content associated with the second submission object set, it is detected whether the branch code in the local repository has been merged into the main line code in the remote repository.
[0009] In one embodiment, detecting whether the branch code in the local repository has been merged into the mainline code in the remote repository according to the data relationship between the submission content associated with the first submission object set and the submission content associated with the second submission object set includes:
[0010] Obtaining a content identifier corresponding to each submitted object in the first submitted object set to obtain a first content identifier set, and obtaining a content identifier corresponding to each submitted object in the second submitted object set to obtain a second content identifier set; the content identifier is a unique identifier used to represent the submitted content associated with the submitted object;
[0011] According to the set relationship between the first content identification set and the second content identification set, it is detected whether the branch code in the local repository has been merged into the main line code in the remote repository.
[0012] In one embodiment, the detecting, according to the set relationship between the first content identification set and the second content identification set, whether the branch code in the local repository has been merged into the main line code in the remote repository includes:
[0013] In the case where the first content identification set is a subset of the second content identification set, determining that the branch code in the local repository has been merged into the main line code in the remote repository;
[0014] When the first content identification set is not a subset of the second content identification set, it is determined that the branch code in the local repository has not been merged into the mainline code in the remote repository.
[0015] In one embodiment, the obtaining of the content identifier corresponding to each submission object in the first submission object set to obtain the first identifier content set includes:
[0016] Obtaining submission content corresponding to each submission object in the first submission object set;
[0017] Performing hash processing on the submitted content corresponding to each submitted object in the first submitted object set to generate a unique content code corresponding to each submitted object in the first submitted object set;
[0018] The content corresponding to each submission object in the first submission object set is uniquely coded as the content identifier corresponding to each submission object in the first submission object set, so as to obtain the first identifier content set.
[0019] In one embodiment, the acquiring the content identifier corresponding to each submission object in the second submission object set to obtain the second content identifier set includes:
[0020] Obtaining submission content corresponding to each submission object in the second submission object set;
[0021] Performing hash processing on the submitted content corresponding to each submitted object in the second submitted object set to generate a unique content code corresponding to each submitted object in the second submitted object set;
[0022] The content unique code corresponding to each submission object in the second submission object set is used as the content identifier corresponding to each submission object in the second submission object set to obtain the second content identifier set.
[0023] In one embodiment, obtaining the first set of submitted objects and the second set of submitted objects includes:
[0024] Obtaining a submission history record of the remote repository; the submission history record includes record information of submission objects existing in the mainline code of the remote repository;
[0025] The first submission object set and the second submission object set are determined according to the submission history record.
[0026] In a second aspect, the present application further provides a code merging state detection device, the device comprising:
[0027] The synchronization module is used to synchronize and save the commit objects of the branch code in the remote repository to the local repository;
[0028] an acquisition module, configured to acquire a first set of submitted objects and a second set of submitted objects; the first set of submitted objects includes submitted objects that exist on the mainline code of the remote repository and do not exist on the local computer; the second set of submitted objects includes submitted objects that exist on the local computer and do not exist on the mainline code of the remote repository;
[0029] A detection module is used to detect whether the branch code in the local repository has been merged into the main line code in the remote repository based on the data relationship between the submission content associated with the first submission object set and the submission content associated with the second submission object set.
[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 the processor implements the steps of the above method when executing the computer program.
[0031] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of the above method when executed by a processor.
[0032] In a fifth aspect, the present application also provides a computer program product, including a computer program, which implements the steps of the above method when executed by a processor.
[0033] The above-mentioned code merge status detection method, device, computer equipment, computer-readable storage medium and computer program product, by synchronously saving the commit objects existing in the branch code in the remote warehouse to the local, and obtaining a first commit object set and a second commit object set; the first commit object set includes commit objects that exist on the main line code of the remote warehouse and do not exist locally; the second commit object set includes commit objects that exist locally and do not exist on the main line code of the remote warehouse; then according to the data relationship between the commit content associated with the first commit object set and the commit content associated with the second commit object set, it is detected whether the branch code in the local has been merged into the main line code in the remote warehouse; in this way, by comparing the data relationship between the commit content associated with the first commit object set and the commit content associated with the second commit object set, the local code changes and the code changes involved in the main line merge commit can be compared in real time or periodically to check whether the local branch code has been merged into the main line code, thereby reducing the tedious process of manual inspection, timely and accurately detecting the abnormal merging problems of branch codes, avoiding the inconsistency of code bases that is easy to occur, and improving the development efficiency of code development projects. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] 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.
[0035] FIG1 is an application environment diagram of a code merging state detection method in one embodiment;
[0036] FIG2 is a schematic diagram of a flow chart of a code merging state detection method in one embodiment;
[0037] FIG3 is a schematic diagram of a flow chart of a code merging state detection method in another embodiment;
[0038] FIG4 is a structural block diagram of a code merging state detection device in one embodiment;
[0039] FIG. 5 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0040] 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.
[0041] A code merge status detection method provided in an embodiment of the present application can be applied in an application environment as shown in FIG1. Among them, the electronic device 102 communicates with the server 104 through a network. The data storage system can store data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on a cloud or other network server. In actual applications, the electronic device 102 synchronously saves the submission objects of the branch code in the remote warehouse to the local; the electronic device 102 obtains a first submission object set and a second submission object set; the first submission object set includes submission objects that exist on the main line code of the remote warehouse and do not exist locally; the second submission object set includes submission objects that exist locally and do not exist on the main line code of the remote warehouse; the electronic device 102 detects whether the branch code in the local has been merged into the main line code in the remote warehouse according to the data relationship between the submission content associated with the first submission object set and the submission content associated with the second submission object set. Among them, the electronic device 102 can be, but is not limited to, various personal computers, laptops, smart phones, and tablet computers. The server 104 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud computing services.
[0042] In an exemplary embodiment, as shown in FIG2 , a code merging state detection method is provided, which is described by taking the method applied to the electronic device in FIG1 as an example, and includes the following steps 202 to 206. Among them:
[0043] Step 202: Synchronize and save the commit object of the branch code in the remote repository to the local repository.
[0044] The remote repository may refer to a remote code repository. Specifically, the method is applied to a distributed version control system, through which developers can track and manage code changes. The distributed version control system can allow multiple users to collaborate on the same code base, and the distributed version control system can ensure the integrity of the code and the accuracy of the historical records.
[0045] In actual applications, the distributed version control system is configured with a remote code repository. The distributed version control system allows users to synchronize local repositories with remote repositories for team collaboration and development. When a user clones a remote repository, the distributed version control system will track certain branches of the remote repository by default.
[0046] Among them, after a new code project is created in a distributed version control system, the code project is configured with a branch by default, namely the main branch. In practical applications, the main branch generally represents a stable version of the code project, and the main branch contains the stable version of the code. In practical applications, the main branch can be named the main line. The main branch containing the stable version of the code can be named the main line code.
[0047] When a new function needs to be developed, the user can create a new functional branch based on the main branch. The functional branch can be a branch of the main line, and the code contained in the functional branch can also be called branch code.
[0048] A commit object may refer to a core data structure that records a code change in a distributed version control system. Each commit object represents a snapshot or the state of the code at a certain point in time; in practical applications, each commit object has a corresponding commit identifier (commit ID). In this application, a commit object may also be referred to as a commit.
[0049] In practice, the submission ID is calculated based on the following:
[0050] 1) Submit object type: In a distributed version control system, each object has a type;
[0051] 2) Submission information: including the name of the submitter account, email address, submission date and time stamp, and a description of the submission;
[0052] 3) Parent commit ID: If the current commit has a parent commit, the parent commit ID of the parent commit will also be included (for the first commit, there is no parent commit;
[0053] 4) Tree object: a snapshot of the entire file tree representing the commit;
[0054] 5) Other metadata: including submission code, etc.
[0055] Therefore, even if two commits modify the same content, they will have different commit IDs because their parent commit IDs are different.
[0056] In a specific implementation, the electronic device synchronously saves the commit object of the branch code in the remote repository to the local. Specifically, the electronic device can submit a log viewing command (for example, a git log command) to the distributed version control system. The log viewing command can obtain the relative complement of the local branch and the remote branch, thereby realizing the synchronization of the local repository and the remote repository. The electronic device can synchronously save the commit object of the branch code in the remote repository to the local, thereby updating the commit information of the remote branch code (i.e., the branch code in the remote repository) saved locally.
[0057] Among them, the local branch can refer to the branch code of the local warehouse, and the remote branch can refer to the branch code of the remote warehouse.
[0058] Step 204, obtain a first set of submitted objects and a second set of submitted objects; the first set of submitted objects includes submitted objects that exist on the mainline code of the remote repository and do not exist locally; the second set of submitted objects includes submitted objects that exist locally and do not exist on the mainline code of the remote repository.
[0059] In a specific implementation, the electronic device can submit a log viewing command (for example, a gitlog command) to the distributed version control system, obtain the submission history of the remote code repository through the log viewing command, and determine the submission objects that exist on the main line code of the remote repository but do not exist locally based on the submission history of the remote code repository, which are recorded as the first submission object set A; similarly, the electronic device determines the submission objects that exist locally but do not exist on the main line code of the remote repository based on the submission history of the remote code repository, which are recorded as the second submission object set B.
[0060] Step 206 , based on the data relationship between the submission content associated with the first submission object set and the submission content associated with the second submission object set, detect whether the branch code in the local repository has been merged into the mainline code in the remote repository.
[0061] In a specific implementation, after the electronic device obtains the first submission object set A and the second submission object set B, it can compare the submission content associated with the first submission object set with the submission content associated with the second submission object set. The electronic device can detect whether the branch code in the local area has been merged into the main line code in the remote repository based on the data relationship between the submission content associated with the first submission object set and the submission content associated with the second submission object set.
[0062] Specifically, when the electronic device detects that the submission content associated with the second submission object set includes the submission content associated with the first submission object set, the electronic device determines that it has been detected that the branch code in the local repository has been merged into the main line code in the remote repository.
[0063] In the above-mentioned code merge status detection method, the commit objects existing in the branch code in the remote warehouse are synchronously saved locally, and a first commit object set and a second commit object set are obtained; the first commit object set includes commit objects that exist on the main line code of the remote warehouse and do not exist locally; the second commit object set includes commit objects that exist locally and do not exist on the main line code of the remote warehouse; then, based on the data relationship between the commit content associated with the first commit object set and the commit content associated with the second commit object set, it is detected whether the branch code in the local area has been merged into the main line code in the remote warehouse; in this way, by comparing the data relationship between the commit content associated with the first commit object set and the commit content associated with the second commit object set, the local code changes and the code changes involved in the main line merge commit can be compared in real time or periodically to check whether the local branch code has been merged into the main line code, thereby reducing the tedious process of manual inspection, timely and accurately detecting abnormal merging problems of branch codes, avoiding the inconsistency of code bases that is easy to occur, and improving the development efficiency of code development projects.
[0064] In an exemplary embodiment, based on the data relationship between the submitted content associated with the first submitted object set and the submitted content associated with the second submitted object set, detecting whether the branch code in the local area has been merged into the main line code in the remote repository includes: obtaining the content identifier corresponding to each submitted object in the first submitted object set to obtain a first content identifier set, and obtaining the content identifier corresponding to each submitted object in the second submitted object set to obtain a second content identifier set; the content identifier is a unique identifier used to characterize the submitted content associated with the submitted object; based on the set relationship between the first content identifier set and the second content identifier set, detecting whether the branch code in the local area has been merged into the main line code in the remote repository.
[0065] In a specific implementation, when the electronic device detects whether the branch code in the local area has been merged into the main line code in the remote repository based on the data relationship between the submitted content associated with the first submitted object set and the submitted content associated with the second submitted object set, the electronic device can obtain the content identifier corresponding to each submitted object in the first submitted object set to obtain a first content identifier set Pa={P(a)|a∈A}; and obtain the content identifier corresponding to each submitted object in the second submitted object set to obtain a second content identifier set Pb={P(b)|b∈B}; then, the electronic device can detect whether the branch code in the local area has been merged into the main line code in the remote repository based on the set relationship between the first content identifier set Pa and the second content identifier set Pb.
[0066] Specifically, when the first content identification set Pa is a subset of the second content identification set Pb (i.e., Pa ⊂ Pb), the electronic device determines that the branch code in the local area has been merged into the main line code in the remote repository; the electronic device can display a first prompt message, through which the user is prompted that the branch code in the local area has been merged into the main line code in the remote repository.
[0067] If the first content identifier set is not a subset of the second content identifier set, the electronic device determines that the local branch code has not been merged into the main line code in the remote repository. The electronic device can display a second prompt message to prompt the user that the local branch code has not been merged into the main line code in the remote repository.
[0068] The technical solution of this embodiment obtains a first content identification set by obtaining a content identification corresponding to each submission object in a first submission object set, and obtains a second content identification set by obtaining a content identification corresponding to each submission object in a second submission object set; a content identification is a unique identification used to characterize the submission content associated with the submission object; according to the set relationship between the first content identification set and the second content identification set, it is possible to quickly compare the submission content associated with the first submission object set with the submission content associated with the second submission object set by determining whether the first content identification set is a subset of the second content identification set, and then efficiently determine whether the branch code in the local area has been merged into the main line code in the remote repository based on the comparison result.
[0069] In an exemplary embodiment, content identifiers corresponding to each submitted object in a first submitted object set are obtained to obtain a first identification content set, including: obtaining submitted content corresponding to each submitted object in the first submitted object set; performing hash processing on the submitted content corresponding to each submitted object in the first submitted object set to generate a content unique code corresponding to each submitted object in the first submitted object set; using the content unique code corresponding to each submitted object in the first submitted object set as the content identifier corresponding to each submitted object in the first submitted object set to obtain a first identification content set.
[0070] In a specific implementation, when the electronic device obtains the content identifier corresponding to each submission object in the first submission object set and obtains the first identification content set, the electronic device can obtain the submission content corresponding to each submission object in the first submission object set; specifically, the electronic device can obtain the submission content corresponding to each submission object in the first submission object set based on the submission ID corresponding to each submission object in the first submission object set; then, the electronic device can hash the submission content corresponding to each submission object in the first submission object set to generate a content unique code corresponding to each submission object in the first submission object set; specifically, the electronic device can calculate the patch-id (patch ID) for each submission object in the first submission object set; then, the electronic device adds the patch ID corresponding to each submission object in the first submission object set to the first identification content set, and records the first identification content set as the set Pa={P(a)|a∈A}.
[0071] The technical solution of this embodiment obtains the submission content corresponding to each submission object in the first submission object set, and performs hash processing on the submission content corresponding to each submission object in the first submission object set to generate a unique content code corresponding to each submission object in the first submission object set, so that the unique content code corresponding to each submission object can be used to characterize the submission content corresponding to each submission object, effectively reducing the amount of data processing of the electronic device in the process of comparing the submission content associated with the first submission object set with the submission content associated with the second submission object set, and improving the efficiency of detecting whether the branch code in the local area has been merged into the main line code in the remote repository.
[0072] In an exemplary embodiment, obtaining content identifiers corresponding to each submitted object in a second submitted object set to obtain a second content identifier set includes: obtaining submitted content corresponding to each submitted object in the second submitted object set; performing hash processing on the submitted content corresponding to each submitted object in the second submitted object set to generate a content unique code corresponding to each submitted object in the second submitted object set; using the content unique code corresponding to each submitted object in the second submitted object set as the content identifier corresponding to each submitted object in the second submitted object set to obtain a second content identifier set.
[0073] In a specific implementation, when the electronic device obtains the content identifier corresponding to each submitted object in the second submitted object set and obtains the second identification content set, the electronic device can obtain the submitted content corresponding to each submitted object in the second submitted object set; specifically, the electronic device can obtain the submitted content corresponding to each submitted object in the second submitted object set based on the submission ID corresponding to each submitted object in the second submitted object set; then, the electronic device can perform hash processing on the submitted content corresponding to each submitted object in the second submitted object set to generate a content unique code corresponding to each submitted object in the second submitted object set; specifically, the electronic device can calculate the patch-id (patch ID) for each submitted object in the second submitted object set; then, the electronic device adds the patch ID corresponding to each submitted object in the second submitted object set to the second identification content set, and records the second identification content set as the set Pb={P(b)|b∈B}.
[0074] The technical solution of this embodiment obtains the submission content corresponding to each submission object in the first submission object set, and performs hash processing on the submission content corresponding to each submission object in the first submission object set to generate a unique content code corresponding to each submission object in the first submission object set, so that the unique content code corresponding to each submission object can be used to characterize the submission content corresponding to each submission object, effectively reducing the amount of data processing of the electronic device in the process of comparing the submission content associated with the first submission object set with the submission content associated with the second submission object set, and improving the efficiency of detecting whether the branch code in the local area has been merged into the main line code in the remote repository.
[0075] In an exemplary embodiment, obtaining the first submission object set and the second submission object set includes: obtaining a submission history record of a remote repository; and determining the first submission object set and the second submission object set according to the submission history record.
[0076] The submission history includes the record information of the submission objects existing in the main line code of the remote repository.
[0077] In a specific implementation, the electronic device can submit a log viewing command (for example, a gitlog command) to the distributed version control system, obtain the submission history of the remote code repository through the log viewing command, and determine the submission objects that exist on the main line code of the remote repository but do not exist locally based on the submission history, which are recorded as the first submission object set A; similarly, the electronic device determines the submission objects that exist locally but do not exist on the main line code of the remote repository based on the submission history of the remote code repository, which are recorded as the second submission object set B.
[0078] The technical solution of this embodiment obtains the submission history of the remote repository, and accurately determines the first submission object set and the second submission object set based on the submission history, thereby facilitating the subsequent accurate detection of whether the branch code in the local area has been merged into the main line code in the remote repository.
[0079] In another embodiment, as shown in FIG. 3 , a code merging state detection method is provided, which is described by taking the method applied to the electronic device in FIG. 1 as an example, and includes the following steps:
[0080] Step S302, synchronously save the commit object of the branch code in the remote repository to the local.
[0081] Step S304, obtaining a first set of submitted objects and a second set of submitted objects; the first set of submitted objects includes submitted objects that exist on the mainline code of the remote repository but not on the local; the second set of submitted objects includes submitted objects that exist on the local but not on the mainline code of the remote repository.
[0082] Step S306: Obtain the submission content corresponding to each submission object in the first submission object set.
[0083] Step S308: Perform hash processing on the submitted content corresponding to each submitted object in the first submitted object set, generate a unique content code corresponding to each submitted object in the first submitted object set, and obtain a first identification content set.
[0084] Step S310: Obtain submission content corresponding to each submission object in the second submission object set.
[0085] Step S312: performing hash processing on the submitted content corresponding to each submitted object in the second submitted object set, generating a unique content code corresponding to each submitted object in the second submitted object set, and obtaining a second content identification set.
[0086] Step S314: when the first content identifier set is a subset of the second content identifier set, it is determined that the branch code in the local repository has been merged into the mainline code in the remote repository.
[0087] It should be noted that the specific limitations of the above steps can refer to the specific limitations of a code merging state detection method mentioned above.
[0088] 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.
[0089] Based on the same inventive concept, the embodiment of the present application also provides a code merge state detection device for implementing the code merge state detection 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 code merge state detection device embodiments provided below can refer to the limitations of the code merge state detection method above, and will not be repeated here.
[0090] In an exemplary embodiment, as shown in FIG4 , a code merging state detection device is provided, comprising:
[0091] Synchronization module 410, used to synchronize and save the commit objects of the branch code in the remote repository to the local repository;
[0092] The acquisition module 420 is used to acquire a first set of submitted objects and a second set of submitted objects; the first set of submitted objects includes submitted objects that exist on the mainline code of the remote repository and do not exist on the local computer; the second set of submitted objects includes submitted objects that exist on the local computer and do not exist on the mainline code of the remote repository;
[0093] The detection module 430 is used to detect whether the branch code in the local repository has been merged into the main line code in the remote repository based on the data relationship between the submission content associated with the first submission object set and the submission content associated with the second submission object set.
[0094] In one embodiment, the detection module 430 is used to obtain the content identifier corresponding to each submission object in the first submission object set to obtain a first content identifier set, and to obtain the content identifier corresponding to each submission object in the second submission object set to obtain a second content identifier set; the content identifier is a unique identifier used to characterize the submission content associated with the submission object; based on the set relationship between the first content identifier set and the second content identifier set, detect whether the branch code in the local has been merged into the main line code in the remote repository.
[0095] In one of the embodiments, the detection module 430 is used to determine that the branch code in the local repository has been merged into the main line code in the remote repository when the first content identification set is a subset of the second content identification set; and to determine that the branch code in the local repository has not been merged into the main line code in the remote repository when the first content identification set is not a subset of the second content identification set.
[0096] In one embodiment, the detection module 430 is used to obtain the submitted content corresponding to each submitted object in the first submitted object set; perform hash processing on the submitted content corresponding to each submitted object in the first submitted object set to generate a content unique code corresponding to each submitted object in the first submitted object set; use the content unique code corresponding to each submitted object in the first submitted object set as the content identifier corresponding to each submitted object in the first submitted object set to obtain the first identifier content set.
[0097] In one embodiment, the detection module 430 is used to obtain the submitted content corresponding to each submitted object in the second submitted object set; perform hash processing on the submitted content corresponding to each submitted object in the second submitted object set to generate a content unique code corresponding to each submitted object in the second submitted object set; use the content unique code corresponding to each submitted object in the second submitted object set as the content identifier corresponding to each submitted object in the second submitted object set to obtain the second content identifier set.
[0098] In one embodiment, the acquisition module 420 is used to obtain the submission history of the remote repository; the submission history includes record information of submission objects existing on the main line code of the remote repository; based on the submission history, the first submission object set and the second submission object set are determined.
[0099] Each module in the above-mentioned code merging state detection device can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above-mentioned modules 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 the operations corresponding to each of the above modules.
[0100] In an exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be shown in FIG5. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit, and an input device. The processor, the memory, and the input / output interface are connected via a system bus, and the communication interface, the display unit, and the input device are connected to the system bus via 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 and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. 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 in a wired or wireless manner, and the wireless manner may be implemented through WIFI, a mobile cellular network, near field communication (NFC) or other technologies. When the computer program is executed by the processor, a code merging state detection method is implemented. The display unit of the computer device is used to form a visually visible picture, which may be a display screen, a projection device, or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.
[0101] Those skilled in the art will understand that the structure shown in FIG. 5 is merely a block diagram of a partial 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 shown in the figure, or combine certain components, or have a different arrangement of components.
[0102] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the above-mentioned method for detecting a code merge state. The steps of the method for detecting a code merge state here may be the steps of the method for detecting a code merge state in each of the above-mentioned embodiments.
[0103] In one embodiment, a computer-readable storage medium is provided, which stores a computer program. When the computer program is executed by a processor, the processor executes the steps of the above-mentioned method for detecting a code merge state. The steps of the method for detecting a code merge state can be the steps of the method for detecting a code merge state in each of the above-mentioned embodiments.
[0104] In one embodiment, a computer program product is provided, including a computer program, which, when executed by a processor, causes the processor to perform the steps of the above-mentioned method for detecting a code merge state. The steps of the method for detecting a code merge state may be the steps of the method for detecting a code merge state in each of the above-mentioned embodiments.
[0105] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0106] 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), magneto resistive 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.
[0107] 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.
[0108] 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 code merging state detection method, characterized in that: The method comprises: Synchronize and save the commit objects of the branch code in the remote repository to the local repository; Obtain a first set of commit objects and a second set of commit objects; the first set of commit objects includes commit objects that exist on the mainline code of the remote repository and do not exist on the local; the second set of commit objects includes commit objects that exist on the local and do not exist on the mainline code of the remote repository; According to the data relationship between the submission content associated with the first submission object set and the submission content associated with the second submission object set, it is detected whether the branch code in the local repository has been merged into the main line code in the remote repository.
2. The method according to claim 1, characterized in that The detecting, based on the data relationship between the submission content associated with the first submission object set and the submission content associated with the second submission object set, whether the branch code in the local repository has been merged into the mainline code in the remote repository includes: Obtaining a content identifier corresponding to each submitted object in the first submitted object set to obtain a first content identifier set, and obtaining a content identifier corresponding to each submitted object in the second submitted object set to obtain a second content identifier set; the content identifier is a unique identifier used to represent the submitted content associated with the submitted object; According to the set relationship between the first content identification set and the second content identification set, it is detected whether the branch code in the local repository has been merged into the main line code in the remote repository.
3. The method according to claim 2, characterized in that The detecting, according to the set relationship between the first content identification set and the second content identification set, whether the branch code in the local repository has been merged into the main line code in the remote repository includes: In the case where the first content identification set is a subset of the second content identification set, determining that the branch code in the local repository has been merged into the main line code in the remote repository; When the first content identification set is not a subset of the second content identification set, it is determined that the branch code in the local repository has not been merged into the mainline code in the remote repository.
4. The method according to claim 2, characterized in that: The acquiring of the content identifier corresponding to each submitted object in the first submitted object set to obtain a first identifier content set includes: Obtaining submission content corresponding to each submission object in the first submission object set; Performing hash processing on the submitted content corresponding to each submitted object in the first submitted object set to generate a unique content code corresponding to each submitted object in the first submitted object set; The content corresponding to each submission object in the first submission object set is uniquely coded as the content identifier corresponding to each submission object in the first submission object set, so as to obtain the first identifier content set.
5. The method according to claim 2, characterized in that: The acquiring the content identifier corresponding to each submission object in the second submission object set to obtain the second content identifier set includes: Obtaining submission content corresponding to each submission object in the second submission object set; Performing hash processing on the submitted content corresponding to each submitted object in the second submitted object set to generate a unique content code corresponding to each submitted object in the second submitted object set; The content unique code corresponding to each submission object in the second submission object set is used as the content identifier corresponding to each submission object in the second submission object set to obtain the second content identifier set.
6. The method according to claim 1, characterized in that The obtaining of the first submitted object set and the second submitted object set includes: Obtaining a submission history record of the remote repository; the submission history record includes record information of submission objects existing in the mainline code of the remote repository; The first submission object set and the second submission object set are determined according to the submission history record.
7. A code merging state detection device, characterized in that: The device comprises: The synchronization module is used to synchronize and save the commit objects of the branch code in the remote repository to the local repository; an acquisition module, configured to acquire a first set of submitted objects and a second set of submitted objects; the first set of submitted objects includes submitted objects that exist on the mainline code of the remote repository and do not exist on the local computer; the second set of submitted objects includes submitted objects that exist on the local computer and do not exist on the mainline code of the remote repository; A detection module is used to detect whether the branch code in the local repository has been merged into the main line code in the remote repository based on the data relationship between the submission content associated with the first submission object set and the submission content associated with the second submission object set.
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.
Citation Information
Patent Citations
Code checking method and device
CN111831554A
Code library design method and detection method for rapid whole network code traceability detection
CN112988217A
Method and system for checking code branch synchronization record, medium and equipment
CN117785211A
GIT-based source code difference automatic analysis method and device and storage medium
CN118377725A
Code processing method and system, computer cluster, medium and program product
WO2022257588A1