A code inspection method and apparatus

15-07-2015 дата публикации
Номер:
CN104780076A
Автор: CUI KAI, NIU JIAN, GAO QIANG, HAN QI
Принадлежит: HANGZHOU H3C TECHNOLOGIES CO LTD
Контакты:
Номер заявки: 12-10-20152099
Дата заявки: 19-03-2015

[1]

Technical Field

[2]

This embodiment relates to the technical field of communication, in particular to a kind of code detection method and apparatus.

[3]

Background Art

[4]

Continuous integration environment can realize the construction of the target software system, deployment, static test, the dynamic test of the automation, thus reach the target software issue of the system can be in real time.

[5]

As shown in Figure 1, continuous integration of the environment, including the following parts:

[6]

(1), the version server: keep the target software system of all code, continuous integration management software and the client code can be downloaded from the server, the client the downloaded code can be modified, then the modification to the version server to be stored.

[7]

(2), client: use by software development personnel, from version server to download the code can, and modifying a code to the version server.

[8]

At present the usual code management process comprises the following steps:

[9]

Step 1. Through the client module from the version of the download server to download system code, and stored in the client terminal;

[10]

Step 2. The client developer changes to the code on the computer, generating modified code;

[11]

Step 3. Through the client to the authentication code has been modified;

[12]

Step 4. If the verification passes, has been submitted by the terminal server to the version modifying code.

[13]

From this it can be seen, in the existing code management process, verification modified code is carried out on a client, therefore, when the development of a large number (for example, several tens, hundreds, thousands of people), the quality of the verification can not be guaranteed, for example: that may have development personnel write right, verification is not carried out; or verification is not full; therefore, to the version on the server to the modified code is very likely errors will appear in the, in this case, if there are other development staff download the error code, so as to be affected by the follow-up process and time is wasted.

[14]

Content of the invention

[15]

The embodiment of the invention provides a code detection method, the method is applied to includes a client, continuous integration server, and in the system of the server version, the method comprises:

[16]

The continuous integration server obtains the client from the server to download the version code change to be repaired and the version number of the difference file, the difference file a with the client code to be modified to modify the generated after modifying code to the difference between the modified code;

[17]

The continuous integration server based on the version number states the version the differential and restore the pre-modifying code document, the modifying code and the check code,

[18]

If code inspection through, the continuous integration server will be the pre-modifying code version server gathers into states.

[19]

Preferably, the integrated server based on the version number states the versionstates continues the differential and restore the pre-modifying code document, comprising:

[20]

The continuous integration server based on the version number states the version from the version of the download server to the version number corresponding to the Edition is carved modifying code to be repaired;

[21]

The continuous integration server on the basis of the difference between to with the modifying code in the file with the modifying code to be repaired have been modifying code to restore the difference between the pre-modifying code.

[22]

Preferably, the integrated server states continues by modifying a code version server gathers into states means, specifically comprising:

[23]

The continuous integration server to the version of the server sends pre-modifying code to the request message of the claw, so that the version of the server received the request message when the states gathers into , the pre-modifying code version server gathers into states.

[24]

Preferably, the integrated server states continues by modifying a code version server gathers into states means, specifically comprising:

[25]

The film has the continuous integration server to the version of the server sends the difference file and states the version into request message of the version number, has been so that the version of the server received the request message when the states gathers into , wait states the version -based modifying code determining the version number, and modifying a code based on the wait and the difference file recovery after the pre-modifying code gathers into states the pre-modifying code version server.

[26]

Preferably, the method further comprises:

[27]

The continuous integration server configuration parameter obtained from the client, the configuration parameters are used for indicating the continuous integration server will be the pre-modifying code to executable file is generated, and the after generating the executable file, indicating whether the executable file is sent to the file server;

[28]

The continuous integration server after checking the confirmation by the web tension, will be based on the configuration parameters of the modified code generating executable file, based on the configuration parameter to determine whether the executable file will be sent to the file server.

[29]

The embodiment of the invention also discloses a continuous integration server, including:

[30]

Acquisition module, for acquiring from the client side to the server to download the version code change to be repaired and the version number of the difference file, the difference file a with the client code to be modified to modify the generated after modifying code to the difference between the modified code;

[31]

Recovery module, based on states the version version number for the differential and restore the pre-modifying code document;

[32]

Detection module, the pre-modifying code is used for checking the code;

[33]

Execution module, used in the when the code checking the, the pre-modifying code version server gathers into states.

[34]

Preferably, the recovery module, in particular for:

[35]

states the version -based server from the version number in the version corresponding to the Edition is carved the version number of the download of code changes to be repaired;

[36]

Modifying a code based on the wait in the file with the differences with the modifying code to be repaired have been modifying code to restore the difference between the pre-modifying code.

[37]

Preferably, the execution module, in particular for:

[38]

The version of the server sends to the claw means of modifying a code request message, so that the version of the server received the request message when the states gathers into , the pre-modifying code version server gathers into states.

[39]

Preferably, the execution module, in particular for:

[40]

The server sends to the version of the difference file and states the version into request message of the version number, has been so that the version of the server received the request message when the states gathers into , wait states the version -based modifying code determining the version number, and modifying a code based on the wait and the difference file recovery after the pre-modifying code gathers into states the pre-modifying code version server.

[41]

Preferably, the apparatus also includes: a configuration module, used for obtaining the configuration parameters from the client, the configuration parameters are used for indicating the continuous integration server will be the pre-modifying code to executable file is generated, and the after generating the executable file, indicating whether the executable file is sent to the file server;

[42]

In the confirmation after checking the web tension, will be based on the configuration parameters of the modified code generating executable file, based on the configuration parameters and determining whether the executable file will be sent to the file server.

[43]

Compared with the prior art, the embodiment of the invention, through the continuous integration server to check the code have been modifying code version server claw again, in the prior art is avoided by the client code is caused by the defect of the inspection, the code is guaranteed only after checking the version server claw, ensuring the quality of the code that the claw, at the same time can also realize the modify any code, the user experience is improved.

[44]

Description of drawings

[45]

Figure 1 is a structure diagram of continuous integrated environment in the prior art;

[46]

Figure 2 is a structure diagram of the embodiment of the invention provides a continuous integration system;

[47]

Figure 3 is a schematic diagram of the process of the embodiment of this invention puts forward a kind of code inspection method;

[48]

Figure 4 is a schematic diagram of the process of the embodiment of this invention puts forward a kind of code inspection method;

[49]

Figure 5 is a structure diagram of the embodiment of the invention provides a continuous integration server.

[50]

Mode of execution

[51]

In the prior art of the above-mentioned problem, this embodiment provides a code inspection method, includes a client method is applied to, continuous integration server, in the system of the server version and, as shown in Figure 2 and Figure 3, comprises the following steps:

[52]

Step 201, continuous integration server obtains the client from the version of the download server to the version number of the code be repaired and the difference file, comprising delivering to the difference file of changes to the client code generated after modifying code to be repaired of the difference of the code has been modified;

[53]

In the present invention a device proposed new, that is, continuous integration server, as shown in Figure 2 is applied to the sustained in the integrated system, the integrated system comprises a client terminal, continuous integration server, version server and, wherein all version stored on the server code; on the server from the client can obtain the required version modification of a modifying code to be repaired, continuous integration server can from the version server and/or client obtaining code, compiled by the SCRIPT or set in advance, automatically complete code compiling, testing, inspection work such as automatic deployment, due to the large amount of compiling, testing work, so a server may not be able to afford, therefore, can be formed by a plurality of continuous integration server server cluster to achieve coordinated operation, can be a portion of the continuous integration server is used for compiling, another part of the continuous integration server used for testing.

[54]

In this case, continuous integration server obtains the client from the version of the download server to the version number of the code be repaired and the difference file, comprising delivering to the difference file of changes to the client code generated after modifying code to be repaired of the difference of the code has been modified, the version in the and through follow-up can have been modifying code to the difference file recovery, wherein the specific process can be as follows:

[55]

Continuous integration server receives a request message sent from the client side, in constructing request message to the client downloads the carrying the version number of the code be repaired, and the difference file of the client is generated; wherein is included in the difference file has been modified with the modifying code to be repaired the distinction code; continuous integration server by constructing and the version number request information for acquiring the difference file, and the recovery of the difference file and version file code has been modified.

[56]

The length of the code can be very long, there may be millions of rows, for example, and modification of the very few, may be on several row or several or several hundred row, in this case, in consideration of saving resources, the client can be based on a version number with the modified code and repaired distinction of the code generated to the difference file (for example, a section of code there are many line, wherein only the section 3 line of, the modified section 3 line of code to A, the difference file is only required to reflect section 3 of the modification can be, in particular, for example, the difference file can be indexed modified code position section 3 line, and the positions of the modified code A, of course, there can be many other forms to reflect, as long as it can reflect the same version number of a modified code and repairs to the difference of the code can be), and the difference file and the version number is sent to the continuous integration server, in order to make continuous integration server through the difference file and the version number in the continuous integration services have been modifying code to recover. Furthermore, the version number is not limited to the difference file and for in constructing request message, as long as the difference file and the version number can be transmitted to the continuous integration server.

[57]

Step 202, and continuous integration server based on the version number has been modifying code to the difference file recovery, and to check the code have been modifying code.

[58]

Specific multiplexing process is as follows:

[59]

Continuous integration server based on the version number from the version of the download server to the version code corresponding to be repaired; continuous integration server based on the modifying code to be repaired of the difference file of the modifying code to be repaired have been modifying code recovery have been modifying code to the difference between.

[60]

Specific, the recovery process is the reverse process of the difference file is generated, in a description of the above-mentioned examples, the difference file after obtained, determine the position of the code modification section 3 row, and after the position of the code A, continuous integration server can be based on the same version number is obtained from the version of code in the server to be repaired, and find section 3 the position of the rows, the section 3 line position to modify the code of the code of the replaced after A, generated after the code of the recovery of the modified code. Through the difference file recovery to the modified code, also, of course, there can be many other ways, according to the specific needs of the difference file structure to carry out the corresponding recovery operation, as long as it can ensure the modified code in a continued continuous integration server recovery can be.

[61]

The above steps are based on the difference file and modifying code version number has been reestablished, however, in practical situations, the code may also be itself relatively short, in this case, also can be directly modified code sent to the continuous integration server, thus continuous integration server can be directly obtained to the modified code, the process-specific can be as follows:

[62]

Continuous integration server receives a request message sent from the client side, constructing request message have been modifying a code carried in the; continuous integration server through constructing the modified request information for acquiring the code.

[63]

Specific, a beneficial to take into account the code, if it is a relatively short length of the code, in this case, the download of the client code change to be repaired have been modifying generated after modifying a code, the code can be modified by constructing a request message is sent to the continuous integration server, continuous integration server can be directly obtained by constructing a request message to the modified code, of course, also is not limited to the construction for modifying a code in the request message, can also be through other message or the modified code is transmitted to the continuous integration server, as long as the modified code is transmitted to the continuous integration server.

[64]

The acquisition after the modifying code, the detected modifying code. As shown in Figure 4 the specific inspection process, is included in the code checking process of compiling, testing, etc. a plurality of inspection process, continuous integration server through the above-mentioned a plurality of process to inspect modifying code, all of the specific needs of the process, the code check will be through.

[65]

Step 203, if the code detected by the, continuous integration server will have been modifying code version server claw.

[66]

After the adoption of the code checks, have been modifying a code needs to be of version server claw there are two kinds of:

[67]

Manner, continuous integration server to the version of the modifying code to have the server send request message of the claw, so that the version server received the request message when the claw, the claw modifying code version server.

[68]

The second method, states continues integrated server to the version of the difference file server, send, carry into and a version number request message, the server has been received so that the version of the request message when the claw, modifying code to be repaired is determined based on a version number, and modifying code to be repaired and on the basis of the difference file recovery have been modified have been modifying code to the code version server claw.

[69]

Furthermore, continuous integration server code already modified in addition, in the present application in a preferred embodiment, can also obtain the configuration parameters from the client (the configuration parameter can be in the step 201 in, continuous integration server in obtaining a modified code be obtained, also can be in checking the access from the client after), user configuration parameter is set on a client, in order to follow-up continuous integration server in determining to already modifying code after checking the code, corresponding to the implementation of the configuration parameters of the preset operation, the preset operation can be the operation of the user-defined according to the requirements of users, the follow-up check the case of the implementation of the user-defined operations, the based on the requirement of the user can be flexibly adjusted.

[70]

Specific, for example, continuous integration server from the client obtaining configuration parameters, configuration parameters are used for indicating continuous integration server code generating the executable file, and after generating the executable file, indicating whether the executable file is sent to the file server; for example, can indicate the format of the generated executable file, for example, is generated. Executable file exe. Sys or executing the file. Com implementation document, as to whether the generated executable file is sent to the file server, the file server can be used, for example, address ip, or in identifying stored in the configuration parameter, in order to make continuous integration server can find the file server based on the configuration parameters, and is sent to the file server; of course, if the configuration parameter does not exist in the file server can be found the parameters or data, the executable file does not need to be sent to the file server, follow-up continuous integration server after checking the check code, based on configuration parameters code generating the executable file (for example, corresponding to different format, of course, can also be of other forms, in particular based on the need to reflect the configuration parameters), based on a configuration parameter to determine whether the executable file is sent to the file server. Of course, in addition, can also be based on the user's need to set up the other preset operation, concrete can based on user-defined, for example, to such a check, in and embodied in configuration parameters, as long as the follow-up continuous integration server after checking the check code can be based on configuration parameters corresponding to the implementation of the configuration parameter can be operated, is not limited to the above-mentioned several kinds of operation, for example, the preset operation may also be based on the scene and the requirement of the user the adjustment of the preset operation, other in this without further recitation.

[71]

The above are based on code checking the situation, as shown in Figure 4, in the specific practical situations, it may not be adopted by the is, for example, may be compiled through not, and/or test no-through, in this case, continuous integration server can check the return code to a client information is not passed.

[72]

The embodiment of the invention discloses a continuous integration server, as shown in Figure 5, including:

[73]

Acquisition module 501, is used for obtaining the client from the version of the download server to the version number of the code be repaired and the difference file, comprising delivering to the difference file of changes to the client code generated after modifying code to be repaired of the difference of the code has been modified;

[74]

Recovery module 502, and based on a version number for the difference file recovery modified code;

[75]

Detection module 503, for the check code modifying code;

[76]

Execution module 504, used in the when the code checking the, the modified code into the version server.

[77]

Specific, recovery module 502, in particular for:

[78]

Based on the version number in the version of the download server to the version code corresponding to be repaired;

[79]

Code and repaired-based change of the difference file of the modifying code to be repaired have been modifying code recovery have been modifying code to the difference between.

[80]

Execution module 504, in particular for:

[81]

Carrying the server sends to the version of the code has been modified into a request message, so that the version server received the request message when the claw, the claw modifying code version server.

[82]

Execution module 504, in particular for:

[83]

Carrying the server sends to the version of the difference file and a version number request message claw, the claw version server in the received request message, modifying code to be repaired is determined based on a version number, and modifying code to be repaired and on the basis of the difference file recovery have been modified have been modifying code to the code version server claw.

[84]

Execution module 504, in particular for:

[85]

Obtaining configuration parameters from the client;

[86]

After the adoption of the check the check code, whether based on configuration parameters according to the modified code is executable file is generated; and/or,

[87]

Based on a configuration parameter will have been modifying code version server claw.

[88]

Compared with the prior art, the embodiment of the invention by continuous integration server to check the code have been modifying code version server claw again, in the prior art is avoided by the client code is caused by the defect of the inspection, the code is guaranteed only after checking the version server claw, ensuring the quality of the code that the claw, at the same time can also realize the modify any code, the user experience is improved.

[89]

Through the above description of the embodiment of the, those of skill in the art can clearly understand that the applications can be realized by hardware, by software can also be added to a common hardware necessary to realize by way of the platform. Based on this understanding, the technical scheme of this application can be embodied in the form of a software product, the software product may be stored in a non-volatile storage medium (can be CD-ROM, U disc, mobile hard disk, and other) in, comprises a plurality of instruction is used for the computer equipment (can be a personal computer, server, or network equipment, and other) the implementation of the application method the scene states each embodiment.

[90]

The technicians of this field can be understood with photos is only a preferred implementation a schematic diagram of the scene, in the Figure the module or process will not necessarily be necessary for the implementation of this application.

[91]

Technical personnel in the field in the scene can be understood the implementation of the module in the device can be distributed in accordance with the implementation of the scene description of the device in implementation of the scene, also can be located in corresponding change of the scene is different from the one or more device. The above-mentioned implementation of the scene of the module can be combined into one module, can also be further divided into a plurality of sub-module.

[92]

The above-mentioned the application Serial number only in order to describe, is not representative of the quality of the scene.

[93]

Disclosed is only the application of the several specific implementation of the scene, however, the application is not limited to this, any those of skill in the art can think of the change should fall into the scope of protection of this application.



[1]

The present application discloses a code inspection method and apparatus. The method includes: a continuous integration server obtains a version number and a difference file of a code to be modified which is downloaded by the client from a version server, the difference file contains the difference between the code to be modified and a modified code generated after the code to be modified is modified by the client; the continuous integration server, based on the version number and the difference file, recovers the modified code, and performs code inspection on the modified code; and if the code inspection is passed, the continuous integration server combines the modified code into the version server. Therefore, before a subsequent operation is executed, the continuous integration server first inspects the code modified by the client, which avoids the defect caused by performing code inspection via the client in the prior art, ensures combination into the version server after passing the code inspection, and increases the user experience.

[1]



1. A code detection method, characterized in that said method is applied includes a client, continuous integration server, and in the system of the server version, the method comprises:

The continuous integration server obtains the client from the server to download the version code change to be repaired and the version number of the difference file, the difference file a with the client code to be modified to modify the generated after modifying code to the difference between the modified code;

The continuous integration server based on the version number states the version the differential and restore the pre-modifying code document, the modifying code and the check code;

If code inspection through, the continuous integration server will be the pre-modifying code version server gathers into states.

2. Method according to Claim 1, characterized in that the continuous integration server based on the version number states the version the differential and restore the pre-modifying code document, comprising:

The continuous integration server based on the version number states the version from the version of the download server to the version number corresponding to the Edition is carved modifying code to be repaired;

The continuous integration server on the basis of the difference between to with the modifying code in the file with the modifying code to be repaired have been modifying code to restore the difference between the pre-modifying code.

3. Method according to Claim 1, characterized in that the continuous integration server will be the pre-modifying code version server gathers into states , specifically comprising:

The continuous integration server to the version of the server sends pre-modifying code to the request message of the claw, so that the version of the server received the request message when the states gathers into , the pre-modifying code version server gathers into states.

4. Method according to Claim 1, characterized in that the continuous integration server will be the pre-modifying code version server gathers into states , specifically comprising:

The film has the continuous integration server to the version of the server sends the difference file and states the version into request message of the version number, has been so that the version of the server received the request message when the states gathers into , wait states the version -based modifying code determining the version number, and modifying a code based on the wait and the difference file recovery after the pre-modifying code gathers into states the pre-modifying code version server.

5. The method of claim, characterized in that the method further comprises:

The continuous integration server configuration parameter obtained from the client, the configuration parameters are used for indicating the continuous integration server will be the pre-modifying code to executable file is generated, and the after generating the executable file, will indicate whether or not the executable file is sent to the file server;

The continuous integration server after checking the confirmation by the web tension, will be based on the configuration parameters of the modified code generating executable file, based on the configuration parameter to determine whether the executable file will be sent to the file server.

6. A continuous integration server, characterized in that comprises:

Acquisition module, for acquiring from the client side to the server to download the version code change to be repaired and the version number of the difference file, the difference file a with the client code to be modified to modify the generated after modifying code to the difference between the modified code;

Recovery module, based on states the version version number for the differential and restore the pre-modifying code document;

Detection module, the pre-modifying code is used for checking the code;

Execution module, used in the when the code checking the, the pre-modifying code version server gathers into states.

7. Equipment according to Claim 6, characterized in that the recovery module, in particular for:

states the version -based server from the version number in the version corresponding to the Edition is carved the version number of the download of code changes to be repaired;

Modifying a code based on the wait in the file with the differences with the modifying code to be repaired have been modifying code to restore the difference between the pre-modifying code.

8. Equipment according to Claim 6, characterized in that the execution module, in particular for:

The version of the server sends to the claw means of modifying a code request message, so that the version of the server received the request message when the states gathers into , the pre-modifying code version server gathers into states.

9. Equipment according to Claim 6, characterized in that the execution module, in particular for:

The server sends to the version of the difference file and states the version into request message of the version number, has been so that the version of the server received the request message when the states gathers into , wait states the version -based modifying code determining the version number, and modifying a code based on the wait and the difference file recovery after the pre-modifying code gathers into states the pre-modifying code version server.

10. Equipment according to Claim 6, characterized in that it also comprises:

Configuration module, used for obtaining the configuration parameters from the client, the configuration parameters are used for indicating the continuous integration server will be the pre-modifying code to executable file is generated, and the after generating the executable file, indicating whether the executable file is sent to the file server;

In the confirmation after checking the web tension, will be based on the configuration parameters of the modified code generating executable file, based on the configuration parameters and determining whether the executable file will be sent to the file server.