CN117931643A - Code verification method, device, equipment and storage medium - Google Patents

Code verification method, device, equipment and storage medium Download PDF

Info

Publication number
CN117931643A
CN117931643A CN202311834517.6A CN202311834517A CN117931643A CN 117931643 A CN117931643 A CN 117931643A CN 202311834517 A CN202311834517 A CN 202311834517A CN 117931643 A CN117931643 A CN 117931643A
Authority
CN
China
Prior art keywords
code
information
management file
verified
verification
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311834517.6A
Other languages
Chinese (zh)
Inventor
张环宇
张仁龙
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
ARM Technology China Co Ltd
Original Assignee
ARM Technology China Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by ARM Technology China Co Ltd filed Critical ARM Technology China Co Ltd
Priority to CN202311834517.6A priority Critical patent/CN117931643A/en
Publication of CN117931643A publication Critical patent/CN117931643A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3604Software analysis for verifying properties of programs

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application provides a code verification method, a device, equipment and a medium, and relates to the technical field of code verification. The method comprises the following steps: responding to a code examination event triggered by code submitting operation, and performing task confirmation according to a pre-stored code management file and the code examination event; extracting identification information of an object code corresponding to the code examination event based on the task confirmation result, and carrying out code submitting operation retrieval according to the identification information; and generating a code management file to be verified according to the retrieval result and the code management file so as to verify the code through the code management file to be verified. The embodiment of the application can obtain the complete code of the functional code for code verification before code warehousing, further quickly find the problem of the code, reduce the influence caused by the problem code, shorten the development time and effectively reduce the development cost.

Description

Code verification method, device, equipment and storage medium
Technical Field
The application relates to the technical field of code verification, in particular to a code verification method, a device, equipment and a storage medium.
Background
In an actual project development process, there may be multiple code warehouses. For example, in the classical web page (web) development Model MVC (Model View Controller, collectively referred to as Model-View-Controller), the Model (Model) layer and the Controller (Controller) layer may be developed by a back-end team, and the View (View) layer by a front-end team. In consideration of the separation of front-end technology and back-end technology, convenience for team management and the like, the whole project is split into two code warehouses which are respectively responsible for development by different teams.
In the development process, one project comprises a plurality of sub-projects for realizing different functions or purposes, and a plurality of code warehouses corresponding to the different sub-projects are needed to be established, and are independent from each other, and the codes in each code warehouse are verified one by one during verification. However, the functional codes are often scattered in multiple sub-items, i.e. there is a dependency relationship between the codes corresponding to different items, but the code stores corresponding to different items are independent of each other. Then, in the code verification stage, when a certain function is verified, codes of a plurality of code warehouses related to the function need to be pulled for verification. However, the continuous integration tool for verification can only verify on a single code repository basis. The problem that a developer can only combine all code warehouses related to a project into one integral file for verification after development is completed, and the code is difficult to find before the code is put in storage is caused, and the code put in storage with the problem can cause interference or linkage influence on the development of other subsequent sub-projects, so that during verification, a large amount of modification is required for the interference or linkage influence, the development time is prolonged, and the development cost is increased.
Disclosure of Invention
The embodiment of the application provides a code verification method, a device, equipment and a medium, which can solve the problem that codes cannot be verified before the codes are put in storage. In order to achieve the object, the embodiments of the present application provide the following solutions.
According to an aspect of an embodiment of the present application, there is provided a code verification method including:
Responding to a code examination event triggered by code submitting operation, and performing task confirmation according to a pre-stored code management file and the code examination event, wherein the code management file comprises information of a code warehouse corresponding to submitted codes;
Extracting identification information of an object code corresponding to the code examination event based on a task confirmation result, and carrying out code submitting operation retrieval according to the identification information, wherein the identification information comprises information indicating code submitting operations corresponding to the object code and the code on which the object code depends;
and generating a code management file to be verified according to the retrieval result and the code management file so as to carry out code verification through the code management file to be verified, wherein the code management file to be verified comprises information of a code warehouse corresponding to the code submitting operation.
In one possible implementation, the code audit event triggered in response to submitting code includes:
connecting with a code examination object based on preset information, wherein the preset information comprises a code management file and code examination object information;
and monitoring code examination events triggered by code submission to a storage object corresponding to the code warehouse.
In one possible implementation manner, the task confirmation according to the pre-stored code management file and the code examination event includes:
If the code examination event is determined to comprise a triggered patch uploading event, matching the code management file with items and branch information in the code examination event;
And if the code management file matched with the project and the branch information exists, determining that the task confirmation is successful.
In one possible implementation manner, the preset information includes a regular expression corresponding to the identification information, and the extracting, based on a task confirmation result, the identification information of the target code corresponding to the code audit event includes:
and if the task confirmation is determined to be successful, acquiring the submitted information corresponding to the code examination event, and extracting the identification information in the submitted information by using a regular expression.
In one possible implementation manner, the preset information includes a regular expression corresponding to the identification information, and the extracting, based on a task confirmation result, the identification information of the target code corresponding to the code audit event includes:
and if the task confirmation is determined to be successful, acquiring the submitted information corresponding to the code examination event, and extracting the identification information in the submitted information by using a regular expression.
In one possible implementation manner, the generating the code management file to be verified according to the search result and the code management file includes:
Determining code information to be verified according to the search result, wherein the code information to be verified comprises information of codes corresponding to the searched submitted code operation;
and modifying the code management file according to the code information to be verified, and generating the code management file to be verified, wherein the code management file to be verified comprises a code warehouse corresponding to the code to be verified.
In one possible implementation manner, the preset information further includes correspondence information between different code management files and code verification objects, and the performing code verification by the code management files to be verified includes:
And submitting the code management file to be verified to the code verification object according to the corresponding information so that the code verification object marks the code to be verified according to the information of code submitting operation corresponding to the code management file to be verified, obtaining the marked code to be verified by utilizing the code management file to be verified, verifying the code to be verified, and modifying the mark of the code to be verified according to a verification result.
According to an aspect of an embodiment of the present application, there is provided a code verification apparatus including:
The task confirmation module is used for responding to a code examination event triggered by submitting a code, and carrying out task confirmation according to a pre-stored code management file and the code examination event, wherein the code management file comprises information of a code warehouse corresponding to the submitted code;
The code submitting operation searching module is used for extracting identification information of the target code corresponding to the code examination event based on a task confirmation result, and carrying out code submitting operation searching according to the identification information, wherein the identification information comprises information indicating code submitting operation corresponding to the code on which the target code depends;
And the management file generation module is used for generating a code management file to be verified according to the search result and the code management file so as to carry out code verification through the code management file to be verified, wherein the code management file to be verified comprises information of a code warehouse corresponding to the code submitting operation.
According to an aspect of an embodiment of the present application, there is provided an electronic device comprising a memory, a processor and a computer program stored on the memory, the processor executing the computer program to carry out the steps of the method as described above.
According to a further aspect of embodiments of the present application, there is provided a computer storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the method as described above.
The technical scheme provided by the embodiment of the application has the beneficial effects that:
The application provides a code verification method, in particular to a code verification method, when responding to a code examination event triggered by submitting a code, task verification is carried out according to a pre-stored code management file and the code examination event, then identification information of a target code is extracted from the code examination event based on a task verification result, submitting code operation search is carried out according to the identification information, and a code management file to be verified is generated according to a search result and the code management file to be verified so as to carry out code verification by utilizing the code management file to be verified. The embodiment of the application can obtain the code submitting operation related to the target code to be verified before the code is put in storage, acquire other codes depending on the target code by utilizing the code submitting operation, realize the verification of the target code according to the target code and the other codes depending on the target code, facilitate the code for code verification to be obtained before the code is put in storage, further quickly find out the problem of the code, reduce the influence caused by the problem code, shorten the development time and effectively reduce the development cost.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following description will simply refer to the drawings that are required to be used in the description of the embodiments of the present application.
FIG. 1 is a flowchart of a code verification method according to an embodiment of the present application;
FIG. 2 is an application deployment schematic diagram of a code verification method according to an embodiment of the present application;
FIG. 3 is a flowchart illustrating a code verification method according to an embodiment of the present application;
FIG. 4 is an exemplary diagram of a code verification method provided by an embodiment of the present application;
FIG. 5 is a block diagram of a code verification device according to an embodiment of the present application;
Fig. 6 is a block diagram of an electronic device according to an embodiment of the present application.
Detailed Description
Embodiments of the present application are described below with reference to the drawings in the present application. It should be understood that the embodiments described below with reference to the drawings are exemplary descriptions for explaining the technical solutions of the embodiments of the present application, and the technical solutions of the embodiments of the present application are not limited.
As used herein, the singular forms "a", "an", "the" and "the" are intended to include the plural forms as well, unless expressly stated otherwise, as understood by those skilled in the art. It will be further understood that the terms "comprises" and "comprising," when used in this specification, specify the presence of stated features, information, data, steps, operations, elements, and/or components, but do not preclude the presence or addition of other features, information, data, steps, operations, elements, components, and/or groups thereof, all of which may be included in the present specification. It will be understood that when an element is referred to as being "connected" or "coupled" to another element, it can be directly connected or coupled to the other element or intervening elements may be present. Further, "connected" or "coupled" as used herein may include wirelessly connected or wirelessly coupled. The term "and/or" as used herein indicates at least one of the items defined by the term, e.g. "a and/or B" indicates implementation as "a", or as "a and B".
For the purpose of making the objects, technical solutions and advantages of the present invention more apparent, the following detailed description of the embodiments of the present invention will be given with reference to the accompanying drawings.
Several terms which the present application relates to will be first described and explained.
Repo a code version management tool encapsulates a series of Git (an open source distributed version control system) commands for unified management of multiple Git repositories. Repo can place multiple Git libraries under the same directory through configuration, thereby simplifying the management of multiple Git version libraries. Taking Android as an example, it consists of thousands of Git warehouses. In Android compiling, after all catalogues and items related to Android are prepared, the Android can be successfully compiled, and the problem of code occurrence in a Git warehouse corresponding to any item can possibly cause compiling failure.
And the management is an XML file and is used for describing the structure and the dependency relationship of the project. The function of this is to instruct Repo tools how to download and manage multiple code stores. It is mainly used to define project structure, manage dependencies, control version, synchronize and update code repository, etc., where:
project structure definition: the Manifest file defines the directory structure and organization of the items. It specifies the name, path and branch information of each code repository, as well as the sub-modules and sub-items in the project.
Dependency management: the Manifest file allows other code warehouses on which the specified items depend. By listing the dependent items in the Manifest file, repo tools can automatically download and synchronize the dependent items, ensuring the integrity and consistency of the items.
Version control: a particular branch, tag, or commit version of each code repository may be specified in the Manifest file. This enables the Repo tool to ensure that each code repository used in the project is in the correct version state.
Synchronization and updating: through the Manifest file, repo tools can easily synchronize and update all code warehouses in the project. It can automatically download new code, check and apply the submission of updates, and resolve possible conflicts. In summary, the Manifest file plays a key role in Repo, which defines the structure and dependencies of the items and helps Repo tool to manage, synchronize, and update code repositories.
Gerrit, a Git-based code review tool, for team collaboration and code quality management, uses web interfaces. The software programmers of the same team can browse the webpage interface of Gerrit by utilizing a webpage browser, and further review the program codes after being modified mutually to determine whether the program codes can be submitted, returned or modified continuously. It uses Git as the underlying version control system.
GERRIT STREAM EVENT, chinese described as a Gerrit stream event, is a mechanism in the Gerrit Code Review system for acquiring and processing events related to code review in real time. It allows the user to obtain real-time notifications and updates about code reviews. GERRIT STREAM EVENT communicates with the Gerrit server via WebSocket protocol to efficiently receive and send events. Using GERRIT STREAM EVENT, a user can subscribe to and listen to a series of events, such as new submissions, comments, votes, merge requests, etc. When related events occur, the Gerrit server will send notifications to subscribed clients, which can receive and process the events in real time. Through GERRIT STREAM EVENT, the user can timely learn the status and progress of code review in order to make corresponding operations and decisions in time. For example, when there is a new comment or vote, a notification may be immediately received via GERRIT STREAM EVENT and the relevant information updated. GERRIT STREAM EVENT provide a way of real-time interaction that enables team members to more efficiently conduct code reviews and collaboration. The method provides quick response and real-time updating capability for users, and improves the visibility and efficiency of development processes.
The Jenkins server is an open source continuous integration and delivery tool, and the main function of the Jenkins server is to automate the software development and delivery process. In this application, the main role is to continue integration: the Jenkins server may be integrated with a version control system (e.g., git, SVN) and automatically trigger the build process when the code is submitted to a version library (e.g., git). It can compile and build applications and run test suites to ensure the quality and stability of the code.
The technical solutions of the embodiments of the present application and technical effects produced by the technical solutions of the present application are described below by describing several exemplary embodiments. It should be noted that the following embodiments may be referred to, or combined with each other, and the description will not be repeated for the same terms, similar features, similar implementation steps, and the like in different embodiments.
The application provides a code verification method, a device, equipment and a medium, which aim to solve at least one technical problem existing in the prior art.
The embodiment of the application provides a code verification method, which can be optionally applied to mobile phones, computers, servers and other intelligent terminals capable of being used for code examination. The code verification method can be used as an application on the intelligent terminal, and can also be used as a piece of hardware arranged on the intelligent terminal, and the intelligent terminal can perform code verification through the application or the hardware.
In one embodiment, as shown in fig. 1, the code verification method includes:
S101: and responding to the code examination event triggered by submitting the code, and performing task confirmation according to the pre-stored code management file and the code examination event.
Optionally, the code management file includes information of a code warehouse corresponding to the submitted code, and the code in the code warehouse is acquired according to the code management file during code verification, and then the code is used for code verification.
In one embodiment, the code management file may be a management file Repo, where the corresponding code repository of the management file is a Git repository, and the codes of the different sub-items in the Repo item are stored in the corresponding Git repository.
Optionally, in response to a code audit event triggered by submitting code, including: connecting with the code examination object based on preset information, wherein the preset information comprises a code management file and code examination object information; and monitoring code examination events triggered by submitting the target code to a storage object corresponding to the code warehouse.
Optionally, the code audit object information includes a code audit object and user credentials by which a user using the code audit object is authenticated. The code submitting method comprises the steps that a code is submitted to a code warehouse storing the code through a code examining object, a code examining event is generated by a storage object corresponding to the code warehouse after the code examining object detects code submitting operation, and the storage object communicates with the code examining object based on the code examining event, so that the code examining object informs an intelligent terminal executing a code verifying method.
In one embodiment, the storage object may be a Git server, the code audit object may be a Gerrit server, the code audit event may be GERRIT STREAM EVENT, the verify of the target code is performed, the verify of the target code related Repo item is read, the file is placed in memory, and the Gerrit server is connected using SSH (Secure Shell), through which the code audit event is monitored. The Git server sends GERRIT STREAM EVENT after receiving the submitted information of the target code, and communicates with the Gerrit server by GERRIT STREAM EVENT.
Optionally, the object code for code verification includes a plurality of patches (patches), which are the smallest units of file changes, for indicating changes made in the code repository. Each submission or update of the object code triggers a patch upload event (PATCH CREATED) in the code audit event.
Optionally, performing task confirmation according to a pre-stored code management file and a code examination event, including: if the code examination event is determined to comprise a triggered patch uploading event, matching the code management file with items and branch information in the code examination event; if the code management file matched with the project and the branch information exists, the task confirmation success is determined, the code management file related to the code examination event exists, the code corresponding to the code examination event is determined to be the target code for code verification, and the next operation is executed. If the code management file matched with the project and the branch information does not exist, determining that the task confirmation fails, and if the code management file related to the code examination event does not exist, ending the code verification operation.
In one embodiment, the patch upload event may be PATCH CREATED in GERRIT STREAM EVENT and the snoop task may be Repo snoop task. And if the triggering patch uploading event is determined according to the monitoring result, matching the item and the branch information contained in GERRIT STREAM EVENT with a pre-stored code management file (which can be a manual. Xml file of Repo) piece by piece. If the matching is to the manifest file conforming to the project and the branch information, the relevant Repo monitoring task is represented, the subsequent flow can be confirmed and executed, and if the matching is not to the project and the branch information, the flow is ended.
S102: and extracting the identification information of the target code corresponding to the code examination event based on the task confirmation result, and carrying out code submitting operation retrieval according to the identification information.
Optionally, the identification information includes information indicating the target code and the commit code operation corresponding to the code on which the target code depends. In the process of submitting the target code, if the target code has no dependency relationship with other codes, the submitted information (Commit Message) corresponding to the target code has no identification information; if the target code has dependent code, the submitting information corresponding to the target code comprises identification information, and the dependent code also comprises the identification information in the corresponding submitting information when submitted.
Alternatively, the identification information may be a unique identifier that includes the function or item to which the target code corresponds and the number of commit code operations to which the interdependent code corresponds. The same identification information is used for all code operations corresponding to the target code and the code depending on the target code.
In one embodiment, a commit code operation is performed to commit object code to the Git store, each object code belonging to only one sub-item, i.e., can only be stored in the Git store to which the sub-item corresponds. If the object code is a separate code, then the commit code operation is performed without adding any special identifier, using the command: the "message" of the Git commit-m is submitted to the Git server, wherein the "Git commit" means "Git commit" which is a command of the Git system and is mainly used for submitting the modified content in the temporary storage area to the local warehouse; "[ message ]" is some remark information. If the functional implementation of the object code is dependent on other code (e.g., for a common object, the code of multiple sub-items (i.e., the code in the Git repository) changes, each changed sub-item generates a Commit (command) that has a dependency between the code corresponding to the Commit, at the time of the Commit, a unique identification name, such as abc, is defined for the function of the code corresponding to the identification name, and the total number of Commit code operations corresponding to the inter-dependent code in the code corresponding to the identification name is confirmed, such as 3 (i.e., there are dependencies between the three Commit code operations).
Optionally, the preset information further includes a regular expression corresponding to the identification information, and the regular expression is used for extracting the identification information in the submitted information. Thus, extracting the identification information of the object code based on the task confirmation result includes: if the task confirmation is successful, acquiring the submitted information corresponding to the code examination event, and extracting the identification information in the submitted information by using the regular expression. The submitted information can be a part of the code examination event, and after the task is confirmed to be successful, the submitted information in the code examination event is identified, and the identification information in the submitted information is identified by using the regular expression.
Optionally, the identification information is a character string, regular expressions corresponding to different submitted information may be the same, or different regular expressions may be used according to differences of submitted information. The regular expression is pre-stored before code verification, and after the code management file corresponding to the code examination event is confirmed to be matched, the pre-stored regular expression is matched with the submitted information in the code examination event, if the matching is successful, the identification information obtained by matching is obtained, and the next submitted code operation search is carried out. If the matching is unsuccessful, determining that the identification information does not exist, and not carrying out code submitting operation searching.
Optionally, the preset information further includes information of a code submission object, and the code submission object information includes a code submission object for submitting the target code and user credentials related to the code submission object. Performing code submitting operation retrieval according to the identification information, including: a commit code operation that retrieves the committed information in the code commit object including the identification information; if the number of the retrieved commit code operations is determined to be consistent with the number in the identification information, determining that the retrieval is complete. The code submitting object can search the submitting information corresponding to the submitting code operation, and the submitting code operation corresponding to the submitting information comprising the identification information is determined to comprise the submitting code operation meeting the searching condition.
In one embodiment, the code submission object is a Gerrit server, and before the target code is submitted, the Gerrit server is used for examining the target code to be submitted, and if the examination is passed, the target code is submitted. And after the identification information corresponding to the target code is extracted through the regular expression, searching the submitted code operation comprising the identification information based on the submitted information in the Gerrit server, and determining that the searching is completed and triggering the next operation after the number of the searched submitted code operations is consistent with the number of the identification information (namely, all the submitted code operations corresponding to the identification information are searched). If the number of the searched submitted code operations is not consistent with the number included in the identification information, the fact that the search is not completed is determined, and the next operation is not executed.
S103: and generating a code management file to be verified according to the retrieval result and the code management file so as to verify the code through the code management file to be verified.
Optionally, the code management file to be verified includes information of a code repository corresponding to the code submitting operation, and the code for code verification can be completely acquired by using the file. Generating a code management file to be verified according to the retrieval result and the code management file, wherein the code management file to be verified comprises: determining code information to be verified according to a search result, wherein the code information to be verified comprises information of a code corresponding to the searched code submitting operation; and modifying the code management file according to the code information to be verified to generate the code management file to be verified, wherein the code management file to be verified comprises a code warehouse corresponding to the code to be verified, so that the code to be verified which needs to be verified can be acquired through the code management file to be verified when the subsequent code is inspected.
In one embodiment, the pre-stored code management file is modified based on information of the code audit event corresponding to the commit code operation. Specifically, the information of patches in all codes corresponding to code submitting operation is obtained according to the code examination event, and the code management file is rewritten based on the information of the patches to generate the code management file to be verified. If the submitted target code is independent and independent of other submitted code operations, the code management file corresponding to the code examination event corresponding to the target code is modified. The modification of the code management file is shown in the attached drawing, and before the modification, the code management file based on Repo items is as follows:
<?xml version="1.0"encoding="UTF-8"?>
<manifest>
<remote name="origin"fetch="ssh://gerrit.com"review="gerrit.com"/>
<default remote="origin"revision="master"/>
<project name="project.git"path="project"/>
<project name="project2.git"path="project2"/>
</manifest>
The modified code management file is:
<?xml version="1.0"encoding="UTF-8"?>
<manifest>
<remote name="origin"fetch="ssh://gerrit.com"review="gerrit.com"/>
<default remote="origin"revision="master"/>
<project name="project.git"path="project"
revision="269c900a0c60ff03e8b1a4211e40024892e1d44a"
upstream="refs/changes/47/10247/1"/>
<project name="project2.git"path="project2"
revision="273265cfe8ff258f463f9fe54dd8ab8daf933e14"
upstream="refs/changes/48/10248/2"/>
</manifest>
The project and project2 in the modified code management file are respectively added with revision and up stream descriptions, which indicate that the code management file is generated according to the information of 2 code operation submissions, namely the code verification needs the code corresponding to 2 dependent code operation submissions.
Optionally, the preset information further includes corresponding information of the code management files and the code verification object, and performing code verification through the code management file to be verified includes: and submitting the code management file to be verified to the code verification object according to the corresponding information so that the code verification object marks the code to be verified according to the submitted code operation corresponding to the code management file to be verified, obtaining the marked code to be verified by utilizing the code management file to be verified, verifying the code to be verified, and modifying the mark of the code to be verified according to the verification result.
In one embodiment, the code management file to be verified is a manifest. After the code management file to be verified is obtained, the generated maniest. Xml file and the information of the code operation submitted corresponding to the file are used as two parameters (MANIFEST _STRING and GERRIT _ COMMITS respectively). And sending the two parameters to Jenkins Repo code verification tasks corresponding to the management. The Jenkins Repo code verification task then begins to trigger a code verification operation. And obtaining the Gerrit server where the code to be verified is located and information of related code submitting operation based on the parameter GERRIT _ COMMITS, and further marking the related code in the Gerrit server by utilizing a Jenkins plug-in (for example, label: verify is set to 0, wherein Verify 0 represents that the code is not verified, verify 1 represents that the code is verified, and Verify-1 represents that the code verification fails). And adds comment parameters Comments describing the built Jenkins Repo code verification task address.
The submitted code management file is then saved as a local file according to parameter MANIFEST _STRING, and the commands repo init and repo sync are executed (repo init is the read-manifest. Xml file initialization repo entry, typically complete command repo init-u [ manifest-path ], repo sync is executed after repo init for synchronizing the code), resulting in a Gerrit code to be verified. And performing code verification in the current code environment according to repo items corresponding to the code management file to be verified. The code verification includes but is not limited to compiling, UT, packaging, testing, and other verification modes. After the code verification task is completed, setting the related Label in the Gerrit server to +1 or-1 according to the verification result and the parameter GERRIT _ COMMITS, jenkins plug-in, adding comment parameters Commits (the parameter can be comment information added on the webpage of Gerrit, which is convenient for a user to check, checking related logs through the code verification task path in the comment if failure occurs, and submitting the related logs in different stages from the previous Comments.
The code verification method of the present application is exemplified in fig. 2 to 4.
In the development of the generation realized based on Repo, the simultaneous development of the projects A and B exists, if the code verification method of the application is not used, the codes depended by each function in the projects A and B need to be manually specified during the code verification (for example, the verification of the specified function A needs to integrate the codes corresponding to the submitted code operation Commit-1 in the project A and the codes corresponding to the submitted code operation Commit-2 in the project B), and then the automatic code function verification is carried out according to the specified result. The code verification method can monitor a locally pre-stored code management file (manicure. Xml) and a code examination event (GERRIT STREAM EVENT) triggered by the Gerrit server when submitting the code operation to obtain the submitted information, further extract the unique identifier from the submitted information, and retrieve the submitted information from the Gerrit server according to the unique identifier after the unique identifier is extracted to comprise the submitted code operation of the unique identifier. And after the number of the submitted code operations is determined to be matched with the number in the identification information, rewriting the code management file according to the retrieved submitted code operations, submitting the rewritten code management file to a corresponding code verification task (such as a Jenkins task) through an API (application program interface) for code verification, marking the code corresponding to the code management file as verify+1 if the code verification is successful, and marking the corresponding code as Verify-1 if the verification is failed.
When responding to a code examination event triggered by submitting codes, the code verification method of the application confirms tasks according to the pre-stored code management files and the code examination event, then extracts the identification information of the target codes from the code examination event based on the task confirmation result, carries out code submitting operation search according to the identification information, and further generates the code management files to be verified according to the search result and the code management files so as to carry out code verification by utilizing the code management files to be verified. The embodiment of the application can obtain the code submitting operation related to the target code to be verified before the code is put in storage, acquire other codes depending on the target code by utilizing the code submitting operation, realize the verification of the target code according to the target code and the other codes depending on the target code, facilitate the code for code verification to be obtained before the code is put in storage, further quickly find out the problem of the code, reduce the influence caused by the problem code, shorten the development time and effectively reduce the development cost.
The application also provides a code verification device, as shown in fig. 5, the code verification device 200 comprises a task confirmation module 210, a code submitting operation retrieval module 220 and a management file generation module 230, wherein the task confirmation module 210 is used for responding to a code examination event triggered by code submitting, and carrying out task confirmation according to a pre-stored code management file and the code examination event, and the code management file comprises information of a code warehouse corresponding to the submitted code; the code submitting operation searching module 220 is configured to extract identification information of an object code corresponding to the code examination event based on a task confirmation result, and perform code submitting operation searching according to the identification information, where the identification information includes information indicating code submitting operation corresponding to a code on which the object code depends; the management file generating module 230 is configured to generate a code management file to be verified according to the search result and the code management file, so as to perform code verification through the code management file to be verified, where the code management file to be verified includes information of a code repository corresponding to the code submitting operation.
Optionally, the code audit event triggered in response to submitting code includes:
connecting with a code examination object based on preset information, wherein the preset information comprises a code management file and code examination object information;
and monitoring code examination events triggered by code submission to a storage object corresponding to the code warehouse.
Optionally, the task confirmation according to the pre-stored code management file and the code examination event includes: if the code examination event is determined to comprise a triggered patch uploading event, matching the code management file with items and branch information in the code examination event; and if the code management file matched with the project and the branch information exists, determining that the task confirmation is successful.
Optionally, the preset information includes a regular expression corresponding to the identification information, and the extracting, based on a task confirmation result, the identification information of the target code corresponding to the code audit event includes: and if the task confirmation is determined to be successful, acquiring the submitted information corresponding to the code examination event, and extracting the identification information in the submitted information by using a regular expression.
Optionally, the preset information further includes information of code submitting objects, the identification information further includes the number of code submitting operations, and the code submitting operation searching according to the identification information includes: a code submission operation for retrieving submitted information in the code submission object, the submitted information including the identification information; and if the number of the searched submitted code operations is determined to be consistent with the number in the identification information, determining that the searching is completed.
Optionally, the generating the code management file to be verified according to the search result and the code management file includes: determining code information to be verified according to the search result, wherein the code information to be verified comprises information of codes corresponding to the searched submitted code operation; and modifying the code management file according to the code information to be verified, and generating the code management file to be verified, wherein the code management file to be verified comprises a code warehouse corresponding to the code to be verified.
Optionally, the preset information further includes correspondence information between different code management files and code verification objects, where the performing code verification by the code management file to be verified includes: and submitting the code management file to be verified to the code verification object according to the corresponding information so that the code verification object marks the code to be verified according to the information of code submitting operation corresponding to the code management file to be verified, obtaining the marked code to be verified by utilizing the code management file to be verified, verifying the code to be verified, and modifying the mark of the code to be verified according to a verification result.
In an alternative embodiment, there is provided an electronic device, as shown in fig. 6, the electronic device 4000 shown in fig. 6 includes: a processor 4001 and a memory 4003. Wherein the processor 4001 is coupled to the memory 4003, such as via a bus 4002. Optionally, the electronic device 4000 may further comprise a transceiver 4004, the transceiver 4004 may be used for data interaction between the electronic device and other electronic devices, such as transmission of data and/or reception of data, etc. It should be noted that, in practical applications, the transceiver 4004 is not limited to one, and the structure of the electronic device 4000 is not limited to the embodiment of the present application.
The processor 4001 may be a CPU (central processing unit), general purpose processor, DSP (digital signal processor), ASIC (ApplicationSpecificIntegratedCircuit ), FPGA (FieldProgrammableGateArray, field programmable gate array) or other programmable logic device, transistor logic device, hardware component, or any combination thereof. Which may implement or perform the various exemplary logic blocks, modules and circuits described in connection with this disclosure. The processor 4001 may also be a combination that implements computing functionality, e.g., comprising one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.
Bus 4002 may include a path to transfer information between the aforementioned components. Bus 4002 may be a PCI (PeripheralComponentInterconnect, peripheral component interconnect standard) bus or an EISA (ExtendedIndustryStandardArchitecture ) bus, or the like. The bus 4002 can be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, the figures are shown with only one bold line, but not with only one bus or one type of bus.
The memory 4003 may be a ROM (read only memory) or other type of static storage device that can store static information and instructions, a RAM (random access memory) or other type of dynamic storage device that can store information and instructions, but may also be an EEPROM (ElectricallyErasableProgrammableReadOnlyMemory ), a CD-ROM (CompactDiscReadOnlyMemory, compact disc) or other optical disc storage, optical disc storage (including compact disc, laser disc, optical disc, digital versatile disc, blu-ray disc, etc.), magnetic disk storage media, other magnetic storage devices, or any other medium that can be used to carry or store a computer program and that can be read by a computer, without limitation.
The memory 4003 is used for storing a computer program for executing an embodiment of the present application, and is controlled to be executed by the processor 4001. The processor 4001 is configured to execute a computer program stored in the memory 4003 to realize the steps shown in the foregoing method embodiment.
The electronic device may be any electronic product that can perform man-machine interaction with an object, for example, a personal computer, a tablet computer, a smart phone, a personal digital assistant (PersonalDigitalAssistant, PDA), a game console, an interactive internet television (InternetProtocolTelevision, IPTV), a smart wearable device, and the like.
The electronic device may also include a network device and/or an object device. Wherein the network device includes, but is not limited to, a single network server, a server group of multiple network servers, or a cloud of a large number of hosts or network servers based on cloud computing (CloudComputing).
The network in which the electronic device is located includes, but is not limited to, the internet, a wide area network, a metropolitan area network, a local area network, a virtual private network (VirtualPrivateNetwork, VPN), and the like.
The embodiment of the application provides a computer storage medium, and a computer program is stored on the computer storage medium, and when the computer program is executed by a processor, the steps and corresponding contents of the foregoing method embodiment can be realized.
The terms "first," "second," "third," "fourth," "1," "2," and the like in the description and in the claims and in the above figures, if any, are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate, such that the embodiments of the application described herein may be implemented in other sequences than those illustrated or otherwise described.
It should be understood that, although various operation steps are indicated by arrows in the flowcharts of the embodiments of the present application, the order in which these steps are implemented is not limited to the order indicated by the arrows. In some implementations of embodiments of the application, the implementation steps in the flowcharts may be performed in other orders as desired, unless explicitly stated herein. Furthermore, some or all of the steps in the flowcharts may include multiple sub-steps or multiple stages based on the actual implementation scenario. Some or all of these sub-steps or phases may be performed at the same time, or each of these sub-steps or phases may be performed at different times, respectively. In the case of different execution time, the execution sequence of the sub-steps or stages can be flexibly configured according to the requirement, which is not limited by the embodiment of the present application.
The foregoing is merely an optional implementation manner of some of the implementation scenarios of the present application, and it should be noted that, for those skilled in the art, other similar implementation manners based on the technical ideas of the present application are adopted without departing from the technical ideas of the scheme of the present application, and the implementation manner is also within the protection scope of the embodiments of the present application.

Claims (10)

1. A code verification method, comprising:
Responding to a code examination event triggered by code submitting operation, and performing task confirmation according to a pre-stored code management file and the code examination event, wherein the code management file comprises information of a code warehouse corresponding to submitted codes;
Extracting identification information of an object code corresponding to the code examination event based on a task confirmation result, and carrying out code submitting operation retrieval according to the identification information, wherein the identification information comprises information indicating code submitting operations corresponding to the object code and the code on which the object code depends;
and generating a code management file to be verified according to the retrieval result and the code management file so as to carry out code verification through the code management file to be verified, wherein the code management file to be verified comprises information of a code warehouse corresponding to the code submitting operation.
2. The code verification method according to claim 1, wherein the code audit event triggered in response to submitting a code comprises:
connecting with a code examination object based on preset information, wherein the preset information comprises a code management file and code examination object information;
and monitoring code examination events triggered by code submission to a storage object corresponding to the code warehouse.
3. The code verification method according to claim 1, wherein said performing task validation based on a pre-stored code management file, said code audit event, comprises:
If the code examination event is determined to comprise a triggered patch uploading event, matching the code management file with items and branch information in the code examination event;
And if the code management file matched with the project and the branch information exists, determining that the task confirmation is successful.
4. The code verification method according to claim 2, wherein the preset information includes a regular expression corresponding to the identification information;
the extracting the identification information of the target code corresponding to the code examination event based on the task confirmation result comprises the following steps:
and if the task confirmation is determined to be successful, acquiring the submitted information corresponding to the code examination event, and extracting the identification information in the submitted information by using a regular expression.
5. The code verification method according to claim 2, wherein the preset information further includes information of a code submission object, and the identification information further includes the number of submitted code operations;
The code submitting operation searching according to the identification information comprises the following steps:
A code submission operation for retrieving submitted information in the code submission object, the submitted information including the identification information;
And if the number of the searched submitted code operations is determined to be consistent with the number in the identification information, determining that the searching is completed.
6. The code verification method according to claim 2, wherein the generating the code management file to be verified according to the search result and the code management file includes:
Determining code information to be verified according to the search result, wherein the code information to be verified comprises information of codes corresponding to the searched submitted code operation;
and modifying the code management file according to the code information to be verified, and generating the code management file to be verified, wherein the code management file to be verified comprises a code warehouse corresponding to the code to be verified.
7. The code verification method according to claim 6, wherein the preset information further includes correspondence information of different code management files and code verification objects, and the performing code verification by the code management files to be verified includes:
And submitting the code management file to be verified to the code verification object according to the corresponding information so that the code verification object marks the code to be verified according to the information of code submitting operation corresponding to the code management file to be verified, obtaining the marked code to be verified by utilizing the code management file to be verified, verifying the code to be verified, and modifying the mark of the code to be verified according to a verification result.
8. A code verification apparatus, comprising:
The task confirmation module is used for responding to a code examination event triggered by submitting a code, and carrying out task confirmation according to a pre-stored code management file and the code examination event, wherein the code management file comprises information of a code warehouse corresponding to the submitted code;
The code submitting operation searching module is used for extracting identification information of the target code corresponding to the code examination event based on a task confirmation result, and carrying out code submitting operation searching according to the identification information, wherein the identification information comprises information indicating code submitting operation corresponding to the code on which the target code depends;
And the management file generation module is used for generating a code management file to be verified according to the search result and the code management file so as to carry out code verification through the code management file to be verified, wherein the code management file to be verified comprises information of a code warehouse corresponding to the code submitting operation.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory, characterized in that the processor executes the computer program to carry out the steps of the method according to any one of claims 1-7.
10. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method according to any of claims 1-7.
CN202311834517.6A 2023-12-27 2023-12-27 Code verification method, device, equipment and storage medium Pending CN117931643A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311834517.6A CN117931643A (en) 2023-12-27 2023-12-27 Code verification method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311834517.6A CN117931643A (en) 2023-12-27 2023-12-27 Code verification method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117931643A true CN117931643A (en) 2024-04-26

Family

ID=90749921

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311834517.6A Pending CN117931643A (en) 2023-12-27 2023-12-27 Code verification method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117931643A (en)

Similar Documents

Publication Publication Date Title
US12093668B2 (en) iOS application program construction method and apparatus, electronic device, and storage medium
US11055078B2 (en) Systems and methods for deploying software products to environments
CN110851167A (en) Container environment updating method, device, equipment and storage medium
CN111651352B (en) Warehouse code merging method and device
CN110727575A (en) Information processing method, system, device and storage medium
CN112581201A (en) Mobile open platform for industrial interconnection manufacturing and implementation method
US10606730B2 (en) Networked digital data processor log file viewer
CN115291935A (en) Component updating method, component updating device, equipment and storage medium
CN116257438A (en) Updating method of interface test case and related equipment
CN111949607A (en) Method, system and device for monitoring UDT file
CN113590172B (en) Code file publishing method, device, equipment and storage medium
CN111367531A (en) Code processing method and device
CN116263659A (en) Data processing method, apparatus, computer program product, device and storage medium
CN107203471B (en) Joint debugging method, service platform and computer storage medium
CN117667109A (en) Environment deployment method and device, electronic equipment and storage medium
CN111506339A (en) Method and device for processing change information of Software Development Kit (SDK)
CN115981718A (en) Code publishing method and device, computer equipment and storage medium
CN116166533A (en) Interface testing method, device, terminal equipment and storage medium
CN117931643A (en) Code verification method, device, equipment and storage medium
CN111935249A (en) Synchronous verification method and device, computer storage medium and electronic equipment
CN116028138B (en) Application publishing method and device
CN114428710B (en) Queue state checking method and device and electronic equipment
CN115185565A (en) Constraint-based article construction method, apparatus, device, medium, and program product
CN118276866A (en) Compiling configuration method, compiling method, electronic device and readable storage medium
CN112749395A (en) Software vulnerability management method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination