Code review method and device, electronic equipment and storage medium
By comparing the code to be submitted with the remote repository, the system identifies and focuses on reviewing the unreviewed code changes, thus solving the problem of time-consuming and labor-intensive code reviews for large-scale software products and improving review efficiency and accuracy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BAIDU ONLINE NETWORK TECH (BEIJIBG) CO LTD
- Filing Date
- 2022-10-31
- Publication Date
- 2026-06-16
AI Technical Summary
Code review for large-scale software products is time-consuming and labor-intensive, and is prone to omissions that lead to errors.
By comparing the code to be submitted with the remote repository, the code changes that have not been reviewed can be identified and focused on for review, reducing the need for multiple full comparisons and improving review efficiency.
This reduces the time and manpower costs of code review, ensures that the focus is on unreviewed parts, and avoids missed errors.
Smart Images

Figure CN115794607B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and more particularly to the fields of big data and artificial intelligence, specifically to methods, apparatus, electronic devices and storage media for code review. Background Technology
[0002] Many software products provide services to users for many years, and as product features are continuously enriched and improved, the product scales up. Correspondingly, the software scale also increases. The risks associated with changes to the product's software code increase, and the cost of fixing them also rises.
[0003] To avoid risks, code that needs to be changed needs to be reviewed, but large-scale code reviews are time-consuming and labor-intensive. Summary of the Invention
[0004] This disclosure provides a method, apparatus, electronic device, and storage medium for code review.
[0005] According to one aspect of this disclosure, a method for code review is provided, comprising:
[0006] Retrieve the code to be committed to the remote repository;
[0007] The code to be submitted is compared with the code to be compared in the remote repository to obtain the first difference;
[0008] Based on the first difference, the unreviewed code changes in the code to be submitted are identified.
[0009] The changed parts of the code need to be thoroughly reviewed.
[0010] In response to the message that the code to be submitted has passed the review, the code to be submitted is committed to the remote repository.
[0011] According to another aspect of this disclosure, an apparatus for code review is provided, comprising:
[0012] The retrieval module is used to retrieve the code to be committed to the remote repository.
[0013] The first comparison module is used to compare the code to be submitted with the code to be compared in the remote repository to obtain the first difference;
[0014] The code change identification module is used to identify the unreviewed code changes in the code to be submitted, based on the first difference.
[0015] The first prompt module is used to indicate which parts of the code have changed and require special review.
[0016] The commit module is used to submit the code to the remote repository in response to a message indicating that the code to be submitted has passed the review.
[0017] According to another aspect of this disclosure, an electronic device is provided, comprising:
[0018] At least one processor; and,
[0019] The memory is communicatively connected to the at least one processor; wherein,
[0020] The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the methods of any embodiment of the present disclosure.
[0021] According to another aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions, wherein the computer instructions are used to cause the computer to perform a method according to any embodiment of this disclosure.
[0022] According to another aspect of this disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements a method according to any embodiment of this disclosure.
[0023] Using the code review method provided in this disclosure can improve the efficiency of code review and also enable reviewers to focus on the code changes that have not been reviewed, thus avoiding the failure to find errors in the code to be submitted due to omissions during the review process.
[0024] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0025] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein:
[0026] Figure 1 This is a flowchart illustrating a code review method provided according to an embodiment of the present disclosure;
[0027] Figure 2 This is a flowchart illustrating a method for obtaining code to be submitted according to an embodiment of the present disclosure;
[0028] Figure 3 This is a scene diagram provided according to an embodiment of the present disclosure;
[0029] Figure 4 This is yet another scene diagram provided according to an embodiment of the present disclosure;
[0030] Figure 5 This is yet another scene diagram provided according to an embodiment of the present disclosure;
[0031] Figure 6 This is a schematic diagram of a code review apparatus according to an embodiment of the present disclosure.
[0032] Figure 7 This is a block diagram of an electronic device used to implement code review in embodiments of this disclosure. Detailed Implementation
[0033] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0034] In software development, code review (CR) is a crucial step that helps identify potential risks and bugs (system vulnerabilities) in the code early on. Code review improves system maintainability and reduces the probability of incidents and the cost of fixing them. Therefore, code can only be added to the code repository for subsequent software version updates after passing the review.
[0035] Current code development typically uses a branching approach, meaning the code repository contains multiple branches, such as the master branch (main branch), dev branch (development branch), and release branch (pre-release branch). Code is written and tested on the dev branch, then committed to the master branch. During the commit, the code on the dev branch is merged with the code on the master branch. After merging, the code is uploaded to a remote code repository and undergoes full integration testing. Once testing is successful, the release branch (with the corresponding version number) is pulled, and the version is released.
[0036] Branch development improves the efficiency of code writing, but each code commit involves multiple code reviews. For example, a code review is required before committing from the dev branch to the master branch; a code review is also required when uploading the merged code to the code repository.
[0037] Therefore, for the same code change, reviewers will conduct multiple code reviews, investing significant manpower and time. To address this, this disclosure proposes a code review method to reduce the cost and improve the efficiency of code review. Figure 1 The diagram shown is a flowchart of the method, including:
[0038] S101. Retrieve the code to be committed to the remote repository.
[0039] In this embodiment of the disclosure, the code obtained by merging the code in the dev branch and the code in the master branch is used as the code to be committed. In some possible implementations, such as Figure 2 As shown, the code to be committed to the remote repository can be obtained using the following methods:
[0040] S201. Obtain the code to be written from the local repository and write it to obtain the written code.
[0041] For example, a developer pulls a code branch from the local repository, writes code on that branch, and obtains the written code (dev). This written code (dev) can then be merged with the code on the master branch. Before merging, reviewers need to review the written code (dev).
[0042] S202. If the review result of the locally written code is determined to be passed, the written code is compared with the code in the local repository to obtain the second difference.
[0043] Because code on the same master branch may be pulled and modified by different developers simultaneously, code conflicts can occur. This can be understood as errors arising from modifications made to the same code block by multiple developers when submitting code.
[0044] S203. If it is determined that there is no code conflict based on the second difference, merge the written code into the local repository to obtain the code to be committed.
[0045] During the review process, in order to review only the changes made to the code to be written compared to the code to be written, this embodiment of the disclosure also compares the code to be written with the code to be written to obtain a third difference; that is, the third difference is the modifications made to the code by the developer. When reviewing the written code, a prompt is given to review the written code based on the third difference. This allows reviewers to focus only on the changes made to the code to be written compared to the code to be written, reducing review time costs and improving review efficiency.
[0046] Based on the identification of the third difference, the following method can be used in this disclosure embodiment to determine whether a code conflict exists:
[0047] If the second and third differences contain the same code block, then a code conflict exists; conversely, if the second and third differences do not contain the same code block, then no code conflict exists.
[0048] Using a comparative method to identify code conflicts clearly pinpoints the location of the conflict, facilitating modification. Furthermore, comparing second and third differences, rather than comparing the code to be written, the written code, and the full code in the local repository, reduces the resources consumed by the comparison.
[0049] S204. If a code conflict is determined based on the second difference, prompt the user to modify the written code and merge the modified written code into the local repository to obtain the code to be committed.
[0050] The feature allows developers to suggest modifications to existing code, specifically highlighting conflicting sections. By pointing out conflicting parts, developers are alerted to fix these issues, preventing new bugs from appearing. This also saves developers time searching for conflicting code, improving development efficiency.
[0051] The code merging methods used in S203 and S204 can be the `merge` function in Git (a distributed version control system). For example, replacing the corresponding changes in the `master` branch with changes made in `dev` branch 1. Other code merging methods can also be used, such as `rebase` in Git. This disclosure does not restrict which method is used for merging.
[0052] Taking the merge method as an example, if a code conflict occurs during the merge process, the system will list the conflicting code blocks in both the written code and the local repository. The code section causing the conflict mentioned in S204 can be highlighted with specific details. Developers can then modify the highlighted code to resolve the conflict. Alternatively, developers can rewrite the conflicted sections to resolve the conflict as well.
[0053] Reviewing existing code can significantly correct errors that occurred during its development. Using a second difference check determines if there are code conflicts between the existing code and the local repository; if conflicts exist, developers are prompted to make the necessary changes. Merging the code to be committed when there are no conflicts reduces the risk of bugs due to these conflicts.
[0054] S102. Compare the code to be submitted with the code to be compared in the remote repository to obtain the first difference.
[0055] S103. Based on the first difference, obtain the code changes in the code to be submitted that have not been reviewed.
[0056] In one possible implementation, the unreviewed code changes can be obtained based on the following method:
[0057] Retrieve the full code of the code to be submitted;
[0058] Retrieve written code and code from a remote repository as reviewed code;
[0059] Verify line by line in the code to be submitted to ensure it is identical to the reviewed code.
[0060] The different parts are the code changes that were not reviewed.
[0061] However, the above method requires a full comparison of three code files (including the file with written code, the code file in the remote repository, and the code file to be committed), which involves a large amount of code and is prone to errors.
[0062] Therefore, in this embodiment of the disclosure, multiple small comparisons can be used to improve the efficiency of obtaining unreviewed code changes, which can be implemented as follows:
[0063] Comparing the third difference with the second difference yields a fourth difference. The third difference is obtained by comparing the code to be written with the code already written, while the second difference is obtained by comparing the code already written with the code in the local repository. Therefore, the fourth difference arises because the code in the local repository was merged with code from other developers before the code to be written was merged with the code in the local repository, resulting in inconsistencies between the code to be written and the code in the local repository.
[0064] Comparing the first and third differences, we get the fifth difference. Similar to the fourth difference, the fifth difference occurs when other code has been submitted to the remote repository and modified the branch of the code to be compared before the code to be submitted is submitted to the remote repository, resulting in inconsistency between the code to be written and the code in the remote repository.
[0065] By comparing the fourth and fifth differences, the unreviewed code changes in the code to be submitted can be identified.
[0066] Using the comparison method of this disclosure to obtain the unreviewed code changes, the location of these unreviewed code changes can be clearly identified, facilitating reviewers to focus on these parts. By employing multiple small-scale comparisons in this method, the amount of code compared can be reduced, comparison efficiency improved, and the code changes requiring focused review can be accurately identified.
[0067] Understandably, the unreviewed code changes obtained after comparison may include: code that was modified to address code conflicts, or code that was omitted or redundant due to misoperation.
[0068] Of course, in some embodiments, whether the unreviewed code change is due to a code conflict can be determined based on the following methods: if the code change is the same code block in the second and third differences, then the code change is determined to be code modified in response to a code conflict; conversely, if the code change is not the same code block in the second and third differences, then the code change is not code modified in response to a code conflict.
[0069] If the changed code is not a modification made to address a code conflict, then compare the fourth difference with the fifth difference. If the changed code is the extra code in the fifth difference relative to the fourth difference, then the changed code is redundant; if the changed code is the extra code in the fourth difference relative to the fifth difference, then the changed code is missing.
[0070] Based on this, different markers can be used to distinguish different code changes. For example, a first marker method can be used to mark code modified to address code conflicts, a second marker method can be used to mark code omitted due to errors, and a third marker method can be used to mark redundant code caused by errors. For example, red can be used to mark code modified to address code conflicts; yellow can be used to mark code omitted due to errors; and blue can be used to mark redundant code caused by errors. It should be noted that this disclosure does not specifically limit the method used to mark different types of unreviewed code changes.
[0071] Differentiating between different types of unreviewed code changes allows for the determination of different review methods during the review process, thereby improving review efficiency.
[0072] S104. The changed parts of the code need to be reviewed carefully.
[0073] In some embodiments, the method for focusing on the reviewed code changes may vary depending on the type of code. For example, for code modified to address code conflicts, reviewers may review the modified code; if no errors are found, the review passes; if errors are found, the review fails, and a message is sent to the developer who submitted the code, prompting them to make corrections. For code that is omitted or redundant due to misoperation, reviewers may confirm with the developer whether the code is omitted or redundant. If it is confirmed to be omitted or redundant, reviewers may supplement the omitted code or delete the redundant parts based on the fourth and fifth differences, and then pass the review with the revised submission.
[0074] Meanwhile, for important code files, this embodiment of the disclosure can simultaneously indicate the code changes that have been reviewed during the writing process when prompting that the code changes need to be reviewed in detail. Reviewers can then conduct a secondary review of these changes or find out which code has been reviewed and which has not.
[0075] Reviewers can choose to review only the unreviewed code changes or all changed code, depending on the specific circumstances. This helps reviewers understand the review status and improves review efficiency. Simultaneously, it allows for focused review of important code files, ensuring that critical code is error-free.
[0076] S105. In response to the message that the code to be submitted has passed the review, submit the code to be submitted to the remote repository.
[0077] Using the first difference to identify unreviewed code changes and marking them as requiring focused review avoids multiple reviews of the same code, improving review efficiency. It also allows reviewers to focus on unreviewed code changes, preventing errors from going undetected during the review process.
[0078] To facilitate understanding of the embodiments of this disclosure, the following example uses a master branch in a remote repository as a local repository to illustrate how the embodiments of this disclosure focus on reviewing code conflict warnings.
[0079] like Figure 3 As shown, there is a master branch 1 in the remote repository. Within master branch 1, there are two code files: code file 1 and code file 2. Code file 1 contains code a through code d, and code file 2 contains code e through code g.
[0080] Developer 1 pulls code file 1 and code file 2 from master branch 1 as dev branch 1 and develops dev branch 1; Developer 2 similarly pulls code file 1 and code file 2 from master branch 1 as dev branch 2 and develops dev branch 2.
[0081] After pulling dev branch 1, as follows: Figure 4 As shown, developer 1 writes code for dev branch 1. The changes A after writing the code include: modifying code b in dev branch 1 code file 1 to obtain code b1, deleting code c in dev branch 1, and modifying code d to obtain code d1. Developer 1 also writes code file 2: adding new code h.
[0082] After writing the code, we obtain the written code. We also obtain the second difference (diffdm1), which is the difference between the developed dev branch 1 and the master branch 1, and the third difference (diffdd1), which is the difference between dev branch 1 before and after development. The contents of diffdm1 and diffdd1 are the same, both representing the code change A in dev branch 1. Comparing the second and third differences, we also obtain a fourth difference (diffi1). Since the second and third differences are the same in this embodiment, the fourth difference (diffi1) is empty.
[0083] Meanwhile, the reviewers will conduct a code review of the code changes in dev branch 1, specifically the code involved in diffdd1.
[0084] After review and approval, the developed dev branch 1 will be merged with master branch 1 using the `merge` function in Git. Specifically, the changes made to dev branch 1 will replace the corresponding changes in master branch 1. Since no other developers merged with master branch 1 before dev branch 1, no code conflicts will occur. After the merge, master branch 1 will be updated to master branch 2. Figure 4 As shown: Code file 1 in master branch 2 includes code a, code b1, and code d1, and code file 2 includes code e-code g and the newly added code h.
[0085] After the merge is complete, upload the code to be committed to the remote repository. At this point, the code to be committed is master branch 2. Before committing to the remote repository, compare the code to be committed with the code to be compared in the remote repository to obtain the first difference, difflm1. Compare difflm1 with diffdd1 to obtain the fifth difference, diffr1. Since no other developers have previously committed the same code branch to the remote repository, and there is no missing or redundant code, the fifth difference, diffr1, is also empty. Because both diffi1 and diffr1 are empty, there are no code changes that require special review.
[0086] Before uploading, reviewers will review the code to be submitted based on the parts of the code that have changed. Since there are no parts of the code that have changed, there is no need to focus on reviewing them. After the review is passed, the code will be uploaded successfully and the remote repository will be updated.
[0087] While developer 1 was developing the code, developer 2 was writing code file 1 for dev branch 2, such as... Figure 5As shown, the code change part B includes: modifying code b to obtain code b2; and writing code file 2 for dev branch 2: modifying code e to obtain code e2.
[0088] After writing the code, we have the completed code. Since developer 1 has merged the same master branch 1, the master branch 1 in the local repository has now changed to master branch 2. We can obtain the third difference before and after development of dev branch 2, diffdd2, which contains the parts that have changed in dev branch 2. We can also obtain the second difference between dev branch 2 and master branch 2 after development, diffdm2. Since dev branch 1 has been merged with the master branch, diffdm2 contains not only the content of diffdd2 but also the content of diffdd1. Comparing diffdd2 and diffdm2, we can see that diff2 contains: the modified code b1 from code file 1, the deleted code c, the modified code d1, and the newly added code h from code file 2.
[0089] At the same time, such as Figure 5 As shown, the reviewers will conduct a code review of the changes in dev branch 2, mainly reviewing the code involved in diffdd2.
[0090] After the review is approved, the developed dev branch 2 will be merged with the master branch 2, and the changes made in dev branch 2 will replace the corresponding parts in master branch 2. Since dev branch 1 and master branch 1 were previously merged, and dev branch 1 also modified code b in code file 1, a code conflict will occur at the location of code b. At this time, developer 2 will be prompted to resolve the code conflict.
[0091] After developer 2 modifies the conflicting code b2 into code b3, the merged dev branch 2 and master branch 2, after resolving the conflict, results in master branch 3. For example... Figure 5 As shown, at this time, code file 1 in master branch 3 includes code a, code b1, and code d1, and code file 2 includes code e2, code f, and code h.
[0092] like Figure 5 As shown, after the merge is complete, the code to be committed is uploaded to the remote repository. At this point, the code to be committed is on the master branch 3. Before uploading, the code to be committed can be compared with the remote repository to obtain the first difference, difflm2. Comparing difflm2 with diffdd2 yields the fifth difference, diffr2. (The text continues with further details about the differences and their relationships.) Figure 5As shown, without any missing or redundant code, diffr2 includes: code b3 modified from code file 1, deleted code c, modified code d1, and newly added code h from code file 2.
[0093] Comparing diffi2 and diffr2, we can see that code b3 in code file 1 differs from code b1, so code b3 is the part of the code that needs to be reviewed.
[0094] Before uploading, reviewers will examine the code to be submitted based on the changes, focusing on code b3. Once the review is passed, the code will be successfully uploaded and the remote repository will be updated.
[0095] Furthermore, when code redundancy or missing code occurs after uploading to a remote repository, this disclosure embodiment can also prompt for a focused review.
[0096] like Figure 5 As shown, suppose an error occurs during upload, resulting in an extra piece of code 'i' in code file 2, indicating code redundancy. In this case, comparing the code to be submitted with the remote repository yields the first difference, `difflm2'`. Comparing `difflm2'` with `diffdd2` yields the fifth difference, `diffr2'`. `diffr2'` includes not only the content of `diffr2` but also the piece of code 'i' from code file 2. Comparing `diff2` and `diffr2'` reveals a difference between code 'b3' and code 'b2' in code file 1, and the presence of code 'i' in code file 2. Therefore, code 'b3' and code 'i' are the code changes that require focused review.
[0097] When code is missing, the method for prompting a focused review in this embodiment is similar to that for code redundancy. As before... Figure 5 As shown, code 'a' was mistakenly deleted, indicating a code omission. At this point, comparing the code to be submitted with the remote repository yields the first difference, "difflm2". Comparing "difflm2" with "diffdd2" yields the fifth difference, "diffr2". "diffr2" includes the missing code 'a' in addition to the content of "diffr2". Comparing "difflm2" and "diffr2", we can see that code b3 differs from code b2 in code file 1, and that code 'a' is missing in code file 2. Therefore, code b3 and the missing code 'a' are the code changes that require focused review.
[0098] It should be further noted that, in addition to highlighting the unreviewed code changes, this embodiment may also simultaneously display the reviewed code changes. For example... Figure 4Taking code file 1 as an example, code b and d in master branch 1 have been modified and changed to code b1 and d1, while code c has been deleted. In addition to highlighting code b, which caused the conflict, as the code change that needs to be reviewed, it can also be pointed out that code d1 and code c are the changes relative to master branch 1. This allows reviewers to understand not only the code that needs to be reviewed, but also the changes to other code.
[0099] Based on the same technical concept, this disclosure also provides an apparatus for code review, such as... Figure 6 As shown, the device includes:
[0100] Module 601 is used to retrieve the code to be committed to the remote repository;
[0101] The first comparison module 602 is used to compare the code to be submitted with the code to be compared in the remote repository to obtain the first difference;
[0102] The code change identification module 603 is used to identify the unreviewed code changes in the code to be submitted based on the first difference.
[0103] The first prompt module 604 is used to indicate that the changed parts of the code need to be reviewed in detail.
[0104] Submission module 605 is used to submit the code to the remote repository in response to a message indicating that the code to be submitted has passed the review.
[0105] In some embodiments, the acquisition module 601 includes:
[0106] The submodule is retrieved to obtain the code to be written from the local repository and then write it to get the written code.
[0107] The comparison submodule is used to compare the written code with the code in the local repository to obtain a second difference, provided that the review result of the written code has been determined to be passed.
[0108] The merge submodule is used to merge written code into the local repository, resulting in code to be committed, provided that no code conflicts are determined based on a second difference; and,
[0109] If a code conflict is determined based on the second difference, the system prompts the user to modify the existing code and merges the modified code into the local repository to obtain the code to be committed.
[0110] In some embodiments, the merged submodule is used for:
[0111] The code section causing the conflict is indicated.
[0112] In some embodiments, the device further includes:
[0113] The second comparison module is used to compare the code to be written with the code that has already been written to obtain the third difference;
[0114] The second prompt module is used to prompt reviews of the written code based on the third difference.
[0115] In some embodiments, the second prompting module is further configured to:
[0116] If the second and third differences contain the same code block, then a code conflict is determined.
[0117] If neither the second nor the third difference contains any writing of the same code block, then there is no code conflict.
[0118] In some embodiments, the code change identification module 603 is used for:
[0119] The third difference is compared with the second difference to obtain the fourth difference;
[0120] By comparing the first and third differences, the fifth difference is obtained;
[0121] By comparing the fourth and fifth differences, the unreviewed code changes in the code to be submitted can be identified.
[0122] In some embodiments, the device further includes:
[0123] The third prompt module is used to prompt when the changed code needs to be reviewed in detail, and also to prompt when the changed code has already been reviewed.
[0124] Figure 7 A schematic block diagram of an example electronic device 700 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0125] like Figure 7As shown, device 700 includes a computing unit 701, which can perform various appropriate actions and processes based on a computer program stored in read-only memory (ROM) 702 or a computer program loaded from storage unit 708 into random access memory (RAM) 703. RAM 703 may also store various programs and data required for the operation of device 700. The computing unit 701, ROM 702, and RAM 703 are interconnected via bus 704. Input / output (I / O) interface 705 is also connected to bus 704.
[0126] Multiple components in device 700 are connected to I / O interface 705, including: input unit 706, such as keyboard, mouse, etc.; output unit 707, such as various types of monitors, speakers, etc.; storage unit 708, such as disk, optical disk, etc.; and communication unit 709, such as network card, modem, wireless transceiver, etc. Communication unit 709 allows device 700 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0127] The computing unit 701 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 701 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 701 performs the various methods and processes described above, such as the code review method. For example, in some embodiments, the code review method may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 708. In some embodiments, part or all of the computer program may be loaded and / or installed on device 700 via ROM 702 and / or communication unit 709. When the computer program is loaded into RAM 703 and executed by the computing unit 701, one or more steps of the code review method described above may be performed. Alternatively, in other embodiments, the computing unit 701 may be configured to perform the code review method by any other suitable means (e.g., by means of firmware).
[0128] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0129] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0130] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0131] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0132] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with embodiments of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.
[0133] A computer system may include clients and servers. Clients and servers are generally located far apart and typically interact via a communication network. The client-server relationship is created by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server in a distributed system, or a server incorporating blockchain technology. Embodiments of this disclosure may employ a server to execute a protein generation method.
[0134] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.
[0135] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the principles of this disclosure should be included within the scope of protection of this disclosure.
Claims
1. A code review method, comprising: Obtaining code to be submitted to a remote repository includes: obtaining code to be written from a local repository and writing it to obtain written code; if the review result of the written code is determined to be passed, comparing the written code with the code in the local repository to obtain a second difference; if it is determined based on the second difference that there is no code conflict, merging the written code into the local repository to obtain code to be submitted. The code to be written is compared with the code that has already been written to obtain the third difference; The code to be submitted is compared with the code to be compared in the remote repository to obtain the first difference; The third difference is compared with the second difference to obtain the fourth difference; the first difference is compared with the third difference to obtain the fifth difference; the fourth difference is compared with the fifth difference to obtain the unreviewed code changes in the code to be submitted. The code changes mentioned above require thorough review. In response to the message that the code to be submitted has passed the review, the code to be submitted is submitted to the remote repository.
2. The method according to claim 1, wherein, Retrieving the code to be committed to the remote repository also includes: If a code conflict is determined based on the second difference, the system prompts the user to modify the written code and merges the modified written code into the local repository to obtain the code to be submitted.
3. The method according to claim 2, wherein, The prompt suggests modifying the existing code, including: The code section causing the conflict is indicated.
4. The method according to claim 2, further comprising: The suggestion is to review the written code based on the third difference.
5. The method according to claim 4, wherein, Determining whether a code conflict exists based on the second difference includes: If the second difference and the third difference contain the writing of the same code block, then a code conflict is determined to exist; If neither the second nor the third difference involves the writing of the same code block, then it is determined that there is no code conflict.
6. The method according to any one of claims 1-4, further comprising: If the code changes mentioned require a thorough review, the system will also indicate the code changes that have already been reviewed.
7. An apparatus for code review, comprising: The retrieval module is used to retrieve code to be committed to the remote repository, including: The submodule is retrieved to obtain the code to be written from the local repository and then write it to get the written code. The comparison submodule is used to compare the written code with the code in the local repository to obtain a second difference if the review result of the written code is determined to be passed. The merging submodule is used to merge the written code into the local repository, based on the second difference, if it is determined that there is no code conflict, to obtain the code to be committed; The second comparison module is used to compare the code to be written with the code already written to obtain the third difference; The first comparison module is used to compare the code to be submitted with the code to be compared in the remote repository to obtain the first difference; The code change identification module is used to: compare the third difference with the second difference to obtain a fourth difference; compare the first difference with the third difference to obtain a fifth difference; and compare the fourth difference with the fifth difference to obtain the unreviewed code changes in the code to be submitted. The first prompt module is used to indicate that the changed parts of the code need to be reviewed carefully. The submission module is used to submit the code to the remote repository in response to the message that the code to be submitted has passed the review.
8. The apparatus according to claim 7, wherein, The merging submodule is also used for: If a code conflict is determined based on the second difference, the system prompts the user to modify the written code and merges the modified written code into the local repository to obtain the code to be submitted.
9. The apparatus according to claim 8, wherein, The merging submodule is used for: The code section causing the conflict is indicated.
10. The apparatus according to claim 8, further comprising: The second prompt module is used to prompt a review of the written code based on the third difference.
11. The apparatus according to claim 10, wherein, The second prompting module is also used for: If the second difference and the third difference contain the writing of the same code block, then a code conflict is determined to exist; If neither the second nor the third difference involves the writing of the same code block, then it is determined that there is no code conflict.
12. The apparatus according to any one of claims 7-10, further comprising: The third prompt module is used to prompt when the code changes require key review, and at the same time, to prompt when the code changes have already been reviewed.
13. An electronic device, comprising: At least one processor; as well as, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-6.
14. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to perform the method according to any one of claims 1-6.
15. A computer program product comprising a computer program that, when executed by a processor, implements the method according to any one of claims 1-6.