CN112612506A - Code change notification method, device, equipment and storage medium - Google Patents

Code change notification method, device, equipment and storage medium Download PDF

Info

Publication number
CN112612506A
CN112612506A CN202011500647.2A CN202011500647A CN112612506A CN 112612506 A CN112612506 A CN 112612506A CN 202011500647 A CN202011500647 A CN 202011500647A CN 112612506 A CN112612506 A CN 112612506A
Authority
CN
China
Prior art keywords
code
file
change
version
code change
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
CN202011500647.2A
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.)
Ping An Puhui Enterprise Management Co Ltd
Original Assignee
Ping An Puhui Enterprise Management 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 Ping An Puhui Enterprise Management Co Ltd filed Critical Ping An Puhui Enterprise Management Co Ltd
Priority to CN202011500647.2A priority Critical patent/CN112612506A/en
Publication of CN112612506A publication Critical patent/CN112612506A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/14Details of searching files based on file metadata
    • G06F16/148File search processing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2358Change logging, detection, and notification
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/903Querying
    • G06F16/90335Query processing
    • G06F16/90344Query processing by using string matching techniques

Abstract

The invention relates to the field of research and development management, and discloses a code change notification method, a device, equipment and a storage medium, which are used for simultaneously notifying user code change information, wherein the method comprises the following steps: receiving a code library of a preset version interval uploaded by a user, and acquiring a code change file from the code library; acquiring a version of a code change file with a change record in a preset version interval; analyzing the version of the code change file with the change record and the adjacent version of the version with the change record to obtain code change position information; acquiring a file path of a code change file, scanning a code base, and acquiring all file paths and corresponding code information in the code base; and matching the file path of the code change file with all file paths in the code library, taking the code information and the code change position corresponding to the successfully matched file path as code change information, and sending the code change information to a user. In addition, the invention also relates to a block chain technology, and the code base can be stored in the block chain.

Description

Code change notification method, device, equipment and storage medium
Technical Field
The present invention relates to the field of research and development management, and in particular, to a method, an apparatus, a device, and a storage medium for notifying a code change.
Background
In the process of code development, the same source code file can be modified by multiple persons, and the modified code is difficult to be rapidly displayed from hundreds of lines or even thousands of lines of codes. Or files with changed codes by the same person can be distributed in different packages (folders) and are searched one by one, so that the searching time is wasted, and therefore, the code change information among different versions is obtained, and the method has important reference significance for searching the code quality problem in the code development and test processes.
The SVN (subversion) is a common tool for code management, and provides a function of acquiring code change information of two comparison versions, however, the code change position information such as a changed file path, a changed line and the like of the code change in the two comparison versions can be obtained by using the SVN, and other code change information such as a packet name, a function, a class name and the like of the code change does not exist, and the code change information has a great significance for analyzing the problem of code quality.
Disclosure of Invention
The invention mainly aims to solve the technical problem that the existing method for acquiring code change information is incomplete.
The first aspect of the present invention provides a method for notifying a code change, including:
receiving a code library of a preset version interval uploaded by a user, and acquiring a code change file from the code library;
acquiring a version of the code change file with a change record in a preset version interval;
analyzing the version of the code change file with the change record and the version adjacent to the version with the change record to obtain code change position information;
acquiring a file path of the code change file, scanning the code base, and acquiring all file paths and corresponding code information in the code base;
matching the file path of the code change file with all file paths in the code library, and taking the code information corresponding to the successfully matched file path and the code change position as code change information;
and sending the code change information to the user.
Optionally, in a first implementation manner of the first aspect of the present invention, the analyzing the version of the code change file with the change record and the version adjacent to the version with the change record to obtain the code change location information includes:
acquiring original code change position information of the version with the change record and the adjacent version through preset log information;
and extracting the version with the adjacent change record and the code change position information of the adjacent version from the original code change information.
Optionally, in a second implementation manner of the first aspect of the present invention, the extracting, from the original code change information, the version with the change record adjacent to the version with the change record and the code change location information of the adjacent version includes:
extracting a changed file path with changed codes from the original code change position information;
extracting a change line corresponding to each changed file path from the original code change position information;
eliminating invalid file paths in the extracted changed file paths to obtain valid file changed paths and corresponding changed lines; and the invalid file path is a file path which is not executable by the corresponding file.
Optionally, in a third implementation manner of the first aspect of the present invention, the obtaining the file path of the code change file and scanning the code library to obtain all file paths and corresponding code information in the code library includes:
acquiring a file path and a corresponding change line of the code change file;
and scanning the code base, and determining corresponding function information in the code change file with the version of the change record according to the file path of the code change file and the corresponding change line.
Optionally, in a fourth implementation manner of the first aspect of the present invention, the determining, according to the file path of the code change file and the corresponding change line, the corresponding function information in the code change file with the version having the change record includes:
in the code change file with the version of the change record, searching a class name and a function name from the initial line of the corresponding change line upwards, and extracting a class name corresponding to the first line with the class name characteristic and a function name corresponding to the first line with the function name characteristic;
in the code change file with the version of the change record, searching a range from the starting line and the ending line of the corresponding change line, searching a class name and a function name downwards, and extracting the class names corresponding to all the lines with the class name characteristics and the function name corresponding to the first line with the function characteristics;
and combining the function name and the class name searched upwards and downwards to obtain corresponding function information in the code change file with the version of the change record.
Optionally, in a fifth implementation manner of the first aspect of the present invention, the matching the file path of the code change file with all file paths in the code library, and using the code information corresponding to the successfully matched file path and the code change position as the code change information includes:
analyzing the character string of the file path, and determining the matching type of the character string according to a preset segment mode separator and a character string format, wherein the matching type comprises a segment mode and a line mode;
setting a matching type identifier according to the matching type, and dividing the character string into a plurality of sub-character strings according to the matching type identifier;
determining a regular expression generation mode for each sub-character string, connecting phrases identified by preset phrase marks in the sub-character strings in different connection modes according to the regular expression generation modes to generate a regular expression of the sub-character strings, and obtaining a regular expression list containing at least one regular expression of the sub-character strings;
and matching the file paths in the code base according to the matching type identification to obtain a matching result.
Optionally, in a sixth implementation manner of the first aspect of the present invention, the analyzing the matching character string, and the determining the matching type of the matching character string according to the preset segment mode separator and the character string format includes:
analyzing the matched character string, and judging whether the format of the matched character string is repeated by taking the segment mode separator as a boundary;
if yes, the matching type is a segment mode;
if not, the matching mode is a line mode.
A second aspect of the present invention provides a code change notification apparatus, including:
the receiving module is used for receiving a code library of a preset version interval uploaded by a user and acquiring a code change file from the code library;
the obtaining module is used for obtaining the version of the code change file with the change record in the preset version interval;
the analysis module is used for analyzing the version of the code change file with the change record and the version adjacent to the version with the change record to obtain code change position information;
the scanning module is used for acquiring the file path of the code change file, scanning the code base and acquiring all the file paths and corresponding code information in the code base;
the matching module is used for matching the file path of the code change file with all file paths in the code library, and taking the code information corresponding to the successfully matched file path and the code change position as code change information;
and the sending module is used for sending the code change information to the user.
Optionally, in a first implementation manner of the second aspect of the present invention, the parsing module includes:
the log query unit is used for acquiring the version with the change record and the original code change position information of the adjacent version through preset log information;
an extracting unit configured to extract, from the original code change information, a version having a change log adjacent thereto and code change position information of the adjacent version.
Optionally, in a second implementation manner of the second aspect of the present invention, the extracting unit is specifically configured to:
extracting a changed file path with changed codes from the original code change position information;
extracting a change line corresponding to each changed file path from the original code change position information;
eliminating invalid file paths in the extracted changed file paths to obtain valid file changed paths and corresponding changed lines; and the invalid file path is a file path which is not executable by the corresponding file.
Optionally, in a third implementation manner of the second aspect of the present invention, the scanning module includes:
acquiring change information, namely acquiring a file path and a corresponding change line of the code change file;
and the function information determining unit is used for scanning the code base and determining corresponding function information in the code change file with the version of the change record according to the file path and the corresponding change line of the code change file.
Optionally, in a fourth implementation manner of the second aspect of the present invention, the function information determining unit is specifically configured to:
in the code change file with the version of the change record, searching a class name and a function name from the initial line of the corresponding change line upwards, and extracting a class name corresponding to the first line with the class name characteristic and a function name corresponding to the first line with the function name characteristic;
in the code change file with the version of the change record, searching a range from the starting line and the ending line of the corresponding change line, searching a class name and a function name downwards, and extracting the class names corresponding to all the lines with the class name characteristics and the function name corresponding to the first line with the function characteristics;
and combining the function name and the class name searched upwards and downwards to obtain corresponding function information in the code change file with the version of the change record.
Optionally, in a fifth implementation manner of the second aspect of the present invention, the matching module is specifically configured to:
analyzing the character string of the file path, and determining the matching type of the character string according to a preset segment mode separator and a character string format, wherein the matching type comprises a segment mode and a line mode;
setting a matching type identifier according to the matching type, and dividing the character string into a plurality of sub-character strings according to the matching type identifier;
determining a regular expression generation mode for each sub-character string, connecting phrases identified by preset phrase marks in the sub-character strings in different connection modes according to the regular expression generation modes to generate a regular expression of the sub-character strings, and obtaining a regular expression list containing at least one regular expression of the sub-character strings;
and matching the file paths in the code base according to the matching type identification to obtain a matching result.
Optionally, in a sixth implementation manner of the second aspect of the present invention, the matching module is specifically configured to:
analyzing the matched character string, and judging whether the format of the matched character string is repeated by taking the segment mode separator as a boundary;
if yes, the matching type is a segment mode;
if not, the matching mode is a line mode.
A third aspect of the present invention provides a code change notification apparatus including: a memory having instructions stored therein and at least one processor, the memory and the at least one processor interconnected by a line; the at least one processor invokes the instructions in the memory to cause the code change notification apparatus to perform the code change notification method described above.
A fourth aspect of the present invention provides a computer-readable storage medium having stored therein instructions, which when run on a computer, cause the computer to execute the code change notification method described above.
In the technical scheme of the invention, a code library of a preset version interval uploaded by a user is received, and a code change file is obtained from the code library; acquiring a version of a code change file with a change record in a preset version interval; analyzing the version of the code change file with the change record and the adjacent version of the version with the change record to obtain code change position information; acquiring a file path of a code change file, scanning a code base, and acquiring all file paths and corresponding code information in the code base; and matching the file path of the code change file with all file paths in the code library, taking the code information and the code change position corresponding to the successfully matched file path as code change information, and sending the code change information to a user. The code change position information is obtained by comparing different versions in the code change file, and the code change information is obtained by matching the code change position information with the code library, so that other code change information such as package names, functions, class names and the like with code changes can be obtained, and the subsequent analysis of the code quality is facilitated. In addition, the invention also relates to a block chain technology, and the code base can be stored in the block chain.
Drawings
FIG. 1 is a schematic diagram of a first embodiment of a code change notification method according to an embodiment of the present invention;
FIG. 2 is a diagram of a second embodiment of a code change notification method according to an embodiment of the present invention;
FIG. 3 is a diagram of a third embodiment of a code change notification method according to an embodiment of the present invention;
FIG. 4 is a diagram of a fourth embodiment of a code change notification method according to the embodiment of the present invention;
FIG. 5 is a schematic diagram of an embodiment of a code change notification apparatus according to the present invention;
FIG. 6 is a schematic diagram of another embodiment of a code change notification apparatus according to an embodiment of the present invention;
fig. 7 is a schematic diagram of an embodiment of a code change notification apparatus according to an embodiment of the present invention.
Detailed Description
In the technical scheme of the invention, a code library of a preset version interval uploaded by a user is received, and a code change file is obtained from the code library; acquiring a version of a code change file with a change record in a preset version interval; analyzing the version of the code change file with the change record and the adjacent version of the version with the change record to obtain code change position information; acquiring a file path of a code change file, scanning a code base, and acquiring all file paths and corresponding code information in the code base; and matching the file path of the code change file with all file paths in the code library, taking the code information and the code change position corresponding to the successfully matched file path as code change information, and sending the code change information to a user. The code change position information is obtained by comparing different versions in the code change file, and the code change information is obtained by matching the code change position information with the code library, so that other code change information such as package names, functions, class names and the like with code changes can be obtained, and the subsequent analysis of the code quality is facilitated. In addition, the invention also relates to a block chain technology, and the code base can be stored in the block chain.
The terms "first," "second," "third," "fourth," and the like in the description and in the claims, as well as in the drawings, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It will be appreciated that the data so used may be interchanged under appropriate circumstances such that the embodiments described herein may be practiced otherwise than as specifically illustrated or described herein. Furthermore, the terms "comprises," "comprising," or "having," and any variations thereof, are intended to cover non-exclusive inclusions, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
For convenience of understanding, a specific flow of the embodiment of the present invention is described below, and referring to fig. 1, a first embodiment of a code change notification method in the embodiment of the present invention includes:
101. receiving a code library of a preset version interval uploaded by a user, and acquiring a code change file from the code library;
it should be understood that the execution subject of the present invention may be a code change notification device, and may also be a terminal or a server, which is not limited herein. The embodiment of the present invention is described by taking a server as an execution subject.
It is emphasized that to ensure privacy and security of data, the codebases described above may be stored in nodes of a blockchain.
In this embodiment, the version described in the present invention is a global concept, and a new version is generated when a code is submitted to a server every time, and one version only corresponds to one submitter (i.e. a changer), and multiple files can be submitted by one submission. Different code files are stored in the code base, wherein the unmodified code file is defined as an unmodified file, and the modified code file is defined as a code change file, so that classification is carried out, and subsequent extraction is facilitated.
In this embodiment, the change of the code by the submitter includes adding a new code, modifying a code and deleting a code, if the same file is changed by two persons at the same time, if the first person modifies the 10 th, 11 th and 12 th lines of the file and submits, and the second person adds two lines of data at the 8 th line of the file, the data modified by the first person last is shifted to the 12 th, 13 th and 14 th lines; if the first person modifies lines 10, 11, 12 of the document and submits and the second person deletes lines 7, 8 of the document and submits, the data that the first person last modified is shifted to lines 8, 9, 10. It can be understood that the change of the same file by more people is the same as the change of the same file by two people.
102. Acquiring a version of a code change file with a change record in a preset version interval;
in this embodiment, because the project file corresponding to the code may need to be submitted and modified for multiple times, but the code may not be modified in each submission, but the version of the file is updated, each code change file may have multiple different versions, the codes between different versions may be different or the same, a corresponding record is performed in each code submission, and when a code change occurs, a record of the code change is performed on the corresponding version.
In this embodiment, after acquiring that the code change file has a version of the change record in the preset version interval, the user may select a version thereof for viewing, and generally, may select the latest version and a version adjacent to the latest version for comparing to obtain the information of the code change.
103. Analyzing the version of the code change file with the change record and the adjacent version of the version with the change record to obtain code change position information;
in this embodiment, the code change position information may be obtained by comparing two adjacent versions of codes, determining the same and different portions in the codes, and defining the codes of the different portions as change codes, where the position corresponding to the code is the code change position information, and in practical applications, the code change position information may also be obtained through an SVN log, where the SVN is a common tool for performing code management as a version control system of an open source code, and the SVN provides a function of obtaining two versions of code change information that are compared, and the specific method is as follows: the SVN logs provided by the SVN can acquire code change information of continuous comparison versions managed by the SVN, such as code change information between new and old versions, and can be called by the 'SVN diff' command provided by the SVN.
In this embodiment, the code change location information includes a file path and a change line of the code change.
104. Acquiring a file path of a code change file, scanning a code base, and acquiring all file paths and corresponding code information in the code base;
in this embodiment, code change position information is obtained by comparing two versions of codes, and code change information of consecutive comparison versions managed by the SVN can be obtained through an SVN log provided by the SVN, and both code change position information only includes a change file path where a code change occurs, code change position information such as a change line, and code change function information such as a function, a package name, and a class name where a code change occurs, but these pieces of information are significant for analyzing code quality, and therefore code change function information such as a function, a package name, and a class name of a code change needs to be obtained.
In this embodiment, after scanning all file paths in the code library, each file path has code information such as a function, a package name, a class name, and the like of a corresponding code change, and the code information such as the function, the package name, the class name, and the like of the code change needs to be determined therefrom as code change information.
105. Matching the file path of the code change file with all file paths in a code library, and taking the code information and the code change position corresponding to the successfully matched file path as code change information;
in this embodiment, the file path and the change line of the code change position may be used as keywords, and the file path and the change line are matched with all file paths in the code library in a regular expression manner, where the file path successfully matched is the file path of the code change position, and therefore the code change information corresponding to the file path successfully matched is also the code change information corresponding to the file path of the code change position.
In practical applications, a regular expression (regular expression) describes a pattern for matching a character string, and may be used to check whether a string contains a certain substring, replace the matched substring, or extract a substring meeting a certain condition from a certain string, or the like.
106. And sending the code change information to the user.
In this embodiment, when the code change information is obtained, the code change information, including a file path, a change line, a function, a package name, a class name, and the like, may be sent to a user, and meanwhile, the changed code may be highlighted by using an existing diff tool, the highlight marking function is performed by directly marking a change point submitted each time with html rich text, green is used for adding a new line, and red is used for deleting a line, so that the user may visually observe the change code on the interface.
In the embodiment, a code library of a preset version interval uploaded by a user is received, and a code change file is obtained from the code library; acquiring a version of a code change file with a change record in a preset version interval; analyzing the version of the code change file with the change record and the adjacent version of the version with the change record to obtain code change position information; acquiring a file path of a code change file, scanning a code base, and acquiring all file paths and corresponding code information in the code base; and matching the file path of the code change file with all file paths in the code library, taking the code information and the code change position corresponding to the successfully matched file path as code change information, and sending the code change information to a user. The code change position information is obtained by comparing different versions in the code change file, and the code change information is obtained by matching the code change position information with the code library, so that other code change information such as package names, functions, class names and the like with code changes can be obtained, and the subsequent analysis of the code quality is facilitated. In addition, the invention also relates to a block chain technology, and the code base can be stored in the block chain.
Referring to fig. 2, a second embodiment of a code change notification method according to the embodiment of the present invention includes:
201. receiving a code library of a preset version interval uploaded by a user, and acquiring a code change file from the code library;
202. acquiring a version of a code change file with a change record in a preset version interval;
the steps 201-202 in the present embodiment are similar to the steps 101-102 in the first embodiment, and are not described herein again.
203. Acquiring original code change position information of a version with a change record and an adjacent version through preset log information;
in this embodiment, the original code change position information is acquired through the SVN log, there may be some invalid information irrelevant to a changed file path and a changed line, and the acquisition of the valid code change position information of the version recorded with the change record and the adjacent version is realized by extracting valid information from the original code change position information acquired through the SVN log.
In this embodiment, the original information recorded in the SVN log may be called by the "svndiff" command. In this embodiment, the version with the change record adjacent to the version with the change record and the code change position information of the adjacent version can be extracted from the original code change information, specifically, a changed file path with a code change can be extracted from the original code change position information, a start/stop line number of the change under the changed file path can be extracted, a changed file path corresponding to the non-executable file and a start/stop line number of the change under the changed file path can be finally removed, and the code change position information can be obtained.
204. Extracting a changed file path with changed codes from the original code change position information;
205. extracting a change line corresponding to each changed file path from the original code change position information;
206. eliminating invalid file paths in the extracted changed file paths to obtain valid file changed paths and corresponding changed lines; the invalid file path is a file path which is not executable by the corresponding file;
in this embodiment, the changed file path in which the code change occurs has a preset path identifier, and the original code change position information provided by the SVN log is read line by line, and when the preset path identifier is read, the corresponding file path is extracted as the changed file path.
In this embodiment, the change line refers to a start/stop line number of a code change in a changed file corresponding to the changed file path, the change line has a preset line identifier, and after the changed file path is extracted, the start/stop line number related to the code change under the changed file path is extracted under the changed file path according to the navigation representation.
In this embodiment, the invalid file path may be determined by an end identifier, and the end identifier of the file path may include: the executable identifier and the non-executable identifier are used, for example, if a file path in the c language is ended by ". m", the corresponding file is an executable file, and if the file path is ended by ". h", the corresponding file is a header file, and the header file is mainly used for setting some declarations, does not contain specific function implementation and is a non-executable file. In this embodiment, by determining the end identifier, the non-executable file is determined, and the non-executable file and the corresponding modified line are removed.
207. Acquiring a file path of a code change file, scanning a code base, and acquiring all file paths and corresponding code information in the code base;
208. matching the file path of the code change file with all file paths in a code library, and taking the code information and the code change position corresponding to the successfully matched file path as code change information;
209. and sending the code change information to a user.
Step 207-.
On the basis of the previous embodiment, the present embodiment describes in detail a process of analyzing a version of the code change file having a change record and an adjacent version of the version having the change record to obtain code change position information, and obtains original code change position information of the version having the change record and the adjacent version through preset log information; extracting code change position information of a version with a change record and an adjacent version from original code change information, wherein the code change position information of the version with the change record and the adjacent version is extracted from the original code change information, and specifically, a change file path for code change is extracted from the original code change position information; extracting a change line corresponding to each changed file path from the original code change position information; eliminating invalid file paths in the extracted changed file paths to obtain valid file changed paths and corresponding changed lines; the invalid file path is a file path which is not executable by the corresponding file, and the subsequent processing flow efficiency is accelerated by eliminating the invalid file path.
Referring to fig. 3, a third embodiment of a code change notification method according to the embodiment of the present invention includes:
301. receiving a code library of a preset version interval uploaded by a user, and acquiring a code change file from the code library;
302. acquiring a version of a code change file with a change record in a preset version interval;
303. analyzing the version of the code change file with the change record and the adjacent version of the version with the change record to obtain code change position information;
the steps 301-303 in the present embodiment are similar to the steps 101-103 in the first embodiment, and are not described herein again.
304. Acquiring a file path and a corresponding change line of a code change file;
305. in a code change file with a version of a change record, searching a class name and a function name from the initial line of a corresponding change line upwards, and extracting a class name corresponding to a first line with class name characteristics and a function name corresponding to a first line with function name characteristics;
in this embodiment, based on the change start behavior, the change file is searched upward line by line, and when the first character string with the class name feature is found, the class name information corresponding to the line is extracted, and the line number is recorded, the programming language types are different, and the line with the class name feature starts differently, for example, in the OC language, the line with the function name feature starts with "@ implementation".
In this embodiment, when searching upwards line by line in the file based on the change start behavior, if the first appearing character string with the function name feature is found, the function name of the changed line is extracted, and the line with the function name feature may be a line beginning with plus-minus sign and parentheses and ending without semicolons.
306. In the code change file with the version of the change record, searching a range from the starting line and the ending line of the corresponding change line, searching a class name and a function name downwards, and extracting the class names corresponding to all the lines with the same class name characteristics and the function name corresponding to the first line with the function characteristics;
307. combining the function name and the class name searched upwards and downwards to obtain corresponding function information in the code change file with the version of the change record;
308. matching the file path of the code change file with all file paths in a code library, and taking the code information and the code change position corresponding to the successfully matched file path as code change information;
309. and sending the code change information to a user.
The embodiment describes in detail a process of acquiring a file path of a code change file, scanning a code base, and acquiring all file paths and corresponding code information in the code base on the basis of the previous embodiment, and acquires the file path of the code change file and a corresponding change line; the method comprises the steps that a code library is scanned, and corresponding function information in a code change file with a version of a change record is determined according to a file path of the code change file and a corresponding change line, wherein the function information corresponding to the code change file with the version of the change record is determined according to the file path of the code change file and the corresponding change line by mainly searching a class name and a function name from the initial line of the corresponding change line upwards in the code change file with the version of the change record, and extracting a class name corresponding to a first line with class name characteristics and a function name corresponding to a first line with function name characteristics; in the code change file with the version of the change record, searching a range from the starting line and the ending line of the corresponding change line, searching a class name and a function name downwards, and extracting the class names corresponding to all the lines with the same class name characteristics and the function name corresponding to the first line with the function characteristics; and combining the function name and the class name searched upwards and downwards to obtain corresponding function information in the code change file with the version of the change record. By the method, the corresponding function information in the code change file with the version of the change record can be quickly determined.
Referring to fig. 4, a fourth embodiment of a code change notification method according to the embodiments of the present invention includes:
401. receiving a code library of a preset version interval uploaded by a user, and acquiring a code change file from the code library;
402. acquiring a version of a code change file with a change record in a preset version interval;
403. analyzing the version of the code change file with the change record and the adjacent version of the version with the change record to obtain code change position information;
404. acquiring a file path of a code change file, scanning a code base, and acquiring all file paths and corresponding code information in the code base;
the steps 401 and 404 in this embodiment are similar to the steps 101 and 104 in the first embodiment, and are not described herein again.
405. Analyzing the character string of the file path, and determining the matching type of the character string according to a preset segment mode separator and a character string format, wherein the matching type comprises a segment mode and a line mode;
in the present embodiment, the matching patterns are divided into a row pattern and a segment pattern according to the separation characteristics of the character strings, wherein the matched content in the matching character strings of the segment pattern is repeated according to a certain fixed format, that is, the character combinations in the whole character string are repeated in the same format, for example, in the character string "123 × 234 × 789", the content is repeated every three characters with "× ″ as a separator. The character strings other than the segment mode are in the line mode. By distinguishing different matching modes, the problem that different character string matching structures need to be written according to different matching contents is avoided.
406. Setting a matching type identifier according to the matching type, and dividing the character string into a plurality of sub-character strings according to the matching type identifier;
407. determining a regular expression generation mode for each sub-character string, connecting phrases identified by preset phrase marks in the sub-character strings in different connection modes according to the regular expression generation mode to generate a regular expression of the sub-character strings, and obtaining a regular expression list containing at least one regular expression of the sub-character strings;
408. matching the file paths in the code base according to the matching type identification to obtain a matching result;
in this embodiment, the matching pattern is divided into a line pattern and a segment pattern, the two patterns are identified by matching type identifiers, when the matching pattern is the line pattern, the matching character string is divided into a plurality of character strings according to line feed characters, that is, each line in the character strings is extracted as a sub-character string, when the matching pattern is the segment pattern, the matching character string is divided into a plurality of matching character strings according to segment pattern separators, that is, repeated parts with the segment pattern separators as boundaries are extracted as sub-character strings, and the matching sub-character strings are extracted with phrases identified by phrase markers and inter-phrase characters therein according to predetermined phrase markers and used as a sub-character string regular expression for character matching.
409. And sending the code information and the code change position corresponding to the successfully matched file path in the matching result to the user as code change information.
On the basis of the previous embodiment, the embodiment describes in detail that a file path of a code change file is matched with all file paths in a code library, code information and a code change position corresponding to the successfully matched file path are used as a code change information process, and a character string matching type of the character string is determined according to a preset segment mode separator and a character string format by analyzing the character string of the file path, wherein the matching type comprises a segment mode and a line mode; setting a matching type identifier according to the matching type, and dividing the character string into a plurality of sub-character strings according to the matching type identifier; determining a regular expression generation mode for each sub-character string, connecting phrases identified by preset phrase marks in the sub-character strings in different connection modes according to the regular expression generation mode to generate a regular expression of the sub-character strings, and obtaining a regular expression list containing at least one regular expression of the sub-character strings; and matching the file paths in the code base according to the matching type identification to obtain a matching result. By the method, all file paths are subjected to regular matching, and file paths meeting conditions can be quickly matched to serve as paths of the code change files.
With reference to fig. 5, the code change notification method in the embodiment of the present invention is described above, and a code change notification apparatus in the embodiment of the present invention is described below, where an embodiment of the code change notification apparatus in the embodiment of the present invention includes:
a receiving module 501, configured to receive a code library of a preset version interval uploaded by a user, and obtain a code change file from the code library;
an obtaining module 502, configured to obtain a version of the code change file having a change record in a preset version interval;
the analysis module 503 is configured to analyze the version of the code change file with the change record and the version adjacent to the version with the change record to obtain code change position information;
a scanning module 504, configured to obtain a file path of the code change file, scan the code base, and obtain all file paths and corresponding code information in the code base;
a matching module 505, configured to match a file path of the code change file with all file paths in the code library, and use code information corresponding to a successfully matched file path and the code change position as code change information;
a sending module 506, configured to send the code change information to the user.
It is emphasized that to ensure privacy and security of data, the codebases described above may be stored in nodes of a blockchain.
In an embodiment of the present invention, the code change notification apparatus executes the code change notification method, and the code change notification method includes: receiving a code library of a preset version interval uploaded by a user, and acquiring a code change file from the code library; acquiring a version of a code change file with a change record in a preset version interval; analyzing the version of the code change file with the change record and the adjacent version of the version with the change record to obtain code change position information; acquiring a file path of a code change file, scanning a code base, and acquiring all file paths and corresponding code information in the code base; and matching the file path of the code change file with all file paths in the code library, taking the code information and the code change position corresponding to the successfully matched file path as code change information, and sending the code change information to a user. The code change position information is obtained by comparing different versions in the code change file, and the code change information is obtained by matching the code change position information with the code library, so that other code change information such as package names, functions, class names and the like with code changes can be obtained, and the subsequent analysis of the code quality is facilitated. In addition, the invention also relates to a block chain technology, and the code base can be stored in the block chain.
Referring to fig. 6, a second embodiment of a code change notification apparatus according to an embodiment of the present invention includes:
a receiving module 501, configured to receive a code library of a preset version interval uploaded by a user, and obtain a code change file from the code library;
an obtaining module 502, configured to obtain a version of the code change file having a change record in a preset version interval;
the analysis module 503 is configured to analyze the version of the code change file with the change record and the version adjacent to the version with the change record to obtain code change position information;
a scanning module 504, configured to obtain a file path of the code change file, scan the code base, and obtain all file paths and corresponding code information in the code base;
a matching module 505, configured to match a file path of the code change file with all file paths in the code library, and use code information corresponding to a successfully matched file path and the code change position as code change information;
a sending module 506, configured to send the code change information to the user.
Wherein, the parsing module 503 includes:
a log querying unit 5031, configured to obtain, through preset log information, original code change location information of the version with the change record and the adjacent version;
an extracting unit 5032, configured to extract, from the original code change information, a version of the adjacent change record and code change location information of the adjacent version.
Optionally, the extracting unit 5032 is specifically configured to:
extracting a changed file path with changed codes from the original code change position information;
extracting a change line corresponding to each changed file path from the original code change position information;
eliminating invalid file paths in the extracted changed file paths to obtain valid file changed paths and corresponding changed lines; and the invalid file path is a file path which is not executable by the corresponding file.
Wherein the scanning module 504 comprises:
change information acquisition 5041, configured to acquire a file path of the code change file and a corresponding change line;
and a function information determination unit 5042, configured to scan the code library, and determine, according to the file path of the code change file and the corresponding change line, corresponding function information in the code change file with the version of the change record.
Optionally, the function information determining unit 5042 is specifically configured to:
in the code change file with the version of the change record, searching a class name and a function name from the initial line of the corresponding change line upwards, and extracting a class name corresponding to the first line with the class name characteristic and a function name corresponding to the first line with the function name characteristic;
in the code change file with the version of the change record, searching a range from the starting line and the ending line of the corresponding change line, searching a class name and a function name downwards, and extracting the class names corresponding to all the lines with the class name characteristics and the function name corresponding to the first line with the function characteristics;
and combining the function name and the class name searched upwards and downwards to obtain corresponding function information in the code change file with the version of the change record.
Optionally, the matching module 505 is specifically configured to:
analyzing the character string of the file path, and determining the matching type of the character string according to a preset segment mode separator and a character string format, wherein the matching type comprises a segment mode and a line mode;
setting a matching type identifier according to the matching type, and dividing the character string into a plurality of sub-character strings according to the matching type identifier;
determining a regular expression generation mode for each sub-character string, connecting phrases identified by preset phrase marks in the sub-character strings in different connection modes according to the regular expression generation modes to generate a regular expression of the sub-character strings, and obtaining a regular expression list containing at least one regular expression of the sub-character strings;
and matching the file paths in the code base according to the matching type identification to obtain a matching result.
Optionally, the matching module is specifically configured to:
analyzing the matched character string, and judging whether the format of the matched character string is repeated by taking the segment mode separator as a boundary;
if yes, the matching type is a segment mode;
if not, the matching mode is a line mode.
In this embodiment, specific functions of each module and a unit structure of a part of modules are described in detail on the basis of the previous embodiment, and by using the device, different versions in a code change file are compared to obtain code change position information, and the code change position information is matched with a code library to obtain code change information, so that other code change information such as a package name, a function, a class name and the like of a code change can be obtained, and subsequent analysis of code quality is facilitated.
Fig. 5 and fig. 6 describe the code change notification apparatus in the embodiment of the present invention in detail from the perspective of the modular functional entity, and the code change notification apparatus in the embodiment of the present invention is described in detail from the perspective of hardware processing.
Fig. 7 is a schematic structural diagram of a code change notification apparatus 700 according to an embodiment of the present invention, where the code change notification apparatus 700 may have a relatively large difference due to different configurations or performances, and may include one or more processors (CPUs) 710 (e.g., one or more processors) and a memory 720, and one or more storage media 730 (e.g., one or more mass storage devices) for storing applications 733 or data 732. Memory 720 and storage medium 730 may be, among other things, transient storage or persistent storage. The program stored in the storage medium 730 may include one or more modules (not shown), each of which may include a series of instruction operations on the code change notification apparatus 700. Further, the processor 710 may be configured to communicate with the storage medium 730, and execute a series of instruction operations in the storage medium 730 on the code change notification apparatus 700 to implement the steps of the code change notification method described above.
The code change notification apparatus 700 may also include one or more power supplies 740, one or more wired or wireless network interfaces 750, one or more input-output interfaces 760, and/or one or more operating systems 731, such as Windows Server, Mac OS X, Unix, Linux, FreeBSD, etc. Those skilled in the art will appreciate that the code change notification apparatus configuration shown in FIG. 7 does not constitute a limitation of the code change notification apparatus provided herein, and may include more or fewer components than shown, or some components in combination, or a different arrangement of components.
The block chain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
The present invention also provides a computer-readable storage medium, which may be a non-volatile computer-readable storage medium, and which may also be a volatile computer-readable storage medium, having stored therein instructions, which, when run on a computer, cause the computer to perform the steps of the code change notification method.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses, and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a read-only memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (10)

1. A code change notification method, characterized by comprising:
receiving a code library of a preset version interval uploaded by a user, and acquiring a code change file from the code library;
acquiring a version of the code change file with a change record in a preset version interval;
analyzing the version of the code change file with the change record and the version adjacent to the version with the change record to obtain code change position information;
acquiring a file path of the code change file, scanning the code base, and acquiring all file paths and corresponding code information in the code base;
matching the file path of the code change file with all file paths in the code library, and taking the code information corresponding to the successfully matched file path and the code change position as code change information;
and sending the code change information to the user.
2. The method of claim 1, wherein the parsing the version of the code change file having a change record and a version adjacent to the version of the change record to obtain code change location information comprises:
acquiring original code change position information of the version with the change record and the adjacent version through preset log information;
and extracting the version with the adjacent change record and the code change position information of the adjacent version from the original code change information.
3. The code change notification method according to claim 2, wherein said extracting, from the original code change information, the version with the change log adjacent thereto and the code change position information of the adjacent version comprises:
extracting a changed file path with changed codes from the original code change position information;
extracting a change line corresponding to each changed file path from the original code change position information;
eliminating invalid file paths in the extracted changed file paths to obtain valid file changed paths and corresponding changed lines; and the invalid file path is a file path which is not executable by the corresponding file.
4. The method of claim 3, wherein the obtaining the file path of the code change file and scanning the code library to obtain all file paths and corresponding code information in the code library comprises:
acquiring a file path and a corresponding change line of the code change file;
and scanning the code base, and determining corresponding function information in the code change file with the version of the change record according to the file path of the code change file and the corresponding change line.
5. The method of claim 4, wherein the scanning the code library to determine corresponding function information in a version of a code change file having a change log based on a file path and corresponding change lines of the code change file comprises:
in the code change file with the version of the change record, searching a class name and a function name from the initial line of the corresponding change line upwards, and extracting a class name corresponding to the first line with the class name characteristic and a function name corresponding to the first line with the function name characteristic;
in the code change file with the version of the change record, searching a range from the starting line and the ending line of the corresponding change line, searching a class name and a function name downwards, and extracting the class names corresponding to all the lines with the class name characteristics and the function name corresponding to the first line with the function characteristics;
and combining the function name and the class name searched upwards and downwards to obtain corresponding function information in the code change file with the version of the change record.
6. The method according to any one of claims 1 to 5, wherein the matching the file path of the code change file with all file paths in the code library, and the using the code information corresponding to the successfully matched file path and the code change position as the code change information includes:
analyzing the character string of the file path, and determining the matching type of the character string according to a preset segment mode separator and a character string format, wherein the matching type comprises a segment mode and a line mode;
setting a matching type identifier according to the matching type, and dividing the character string into a plurality of sub-character strings according to the matching type identifier;
determining a regular expression generation mode for each sub-character string, connecting phrases identified by preset phrase marks in the sub-character strings in different connection modes according to the regular expression generation modes to generate a regular expression of the sub-character strings, and obtaining a regular expression list containing at least one regular expression of the sub-character strings;
and matching the file paths in the code base according to the matching type identification to obtain a matching result.
7. The method of claim 6, wherein the parsing the matching string and determining the matching type of the matching string according to a preset segment pattern separator and a string format comprises:
analyzing the matched character string, and judging whether the format of the matched character string is repeated by taking the segment mode separator as a boundary;
if yes, the matching type is a segment mode;
if not, the matching mode is a line mode.
8. A code change notification device, characterized by comprising:
the receiving module is used for receiving a code library of a preset version interval uploaded by a user and acquiring a code change file from the code library;
the obtaining module is used for obtaining the version of the code change file with the change record in the preset version interval;
the analysis module is used for analyzing the version of the code change file with the change record and the version adjacent to the version with the change record to obtain code change position information;
the scanning module is used for acquiring the file path of the code change file, scanning the code base and acquiring all the file paths and corresponding code information in the code base;
the matching module is used for matching the file path of the code change file with all file paths in the code library, and taking the code information corresponding to the successfully matched file path and the code change position as code change information;
and the sending module is used for sending the code change information to the user.
9. A code change notification apparatus characterized by comprising: a memory having instructions stored therein and at least one processor, the memory and the at least one processor interconnected by a line;
the at least one processor invoking the instructions in the memory to cause the code change notification apparatus to perform the code change notification method of any of claims 1-7.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, implements a code change notification method according to any one of claims 1 to 7.
CN202011500647.2A 2020-12-18 2020-12-18 Code change notification method, device, equipment and storage medium Pending CN112612506A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011500647.2A CN112612506A (en) 2020-12-18 2020-12-18 Code change notification method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011500647.2A CN112612506A (en) 2020-12-18 2020-12-18 Code change notification method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN112612506A true CN112612506A (en) 2021-04-06

Family

ID=75240836

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011500647.2A Pending CN112612506A (en) 2020-12-18 2020-12-18 Code change notification method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112612506A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113138769A (en) * 2021-05-17 2021-07-20 上海交通大学 Biological analysis code storage method and device based on cloud storage
CN116010997A (en) * 2023-03-20 2023-04-25 中国信息通信研究院 Data resource hosting method and device based on continuity check of blockchain

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113138769A (en) * 2021-05-17 2021-07-20 上海交通大学 Biological analysis code storage method and device based on cloud storage
CN116010997A (en) * 2023-03-20 2023-04-25 中国信息通信研究院 Data resource hosting method and device based on continuity check of blockchain

Similar Documents

Publication Publication Date Title
US7316015B2 (en) Method, apparatus, and program for constructing an execution environment, and computer readable medium recording program thereof
JP4324976B2 (en) File difference management device, file difference management method, and file difference management program
CN102647414B (en) Protocol analysis method, protocol analysis device and protocol analysis system
CN112612506A (en) Code change notification method, device, equipment and storage medium
CN107402798B (en) Method and apparatus for converting sequencing scripts to reuse JCL in different coding environments
CN112329418A (en) Parallel approval method, equipment and computer readable storage medium
CN112306549A (en) Interface document configuration method, device, equipment and storage medium
CN113420537A (en) Method, device, equipment and storage medium for processing electronic form data
Ma et al. Chaining for accurate alignment of erroneous long reads to acyclic variation graphs
JP2001167086A (en) Method and device for managing document with digital signature
JP3784060B2 (en) Database search system, search method and program thereof
JP2005235209A (en) Sequence indexing method and system
JP4477531B2 (en) Data import method and data import apparatus
CN114676126B (en) Database-based data verification method, device, equipment and storage medium
CN111639248A (en) Webpage data crawling method, device, equipment and storage medium
CN115185980B (en) Hospital medical record data retrieval method, device, equipment and storage medium
JP2006065467A (en) Device for creating data extraction definition information and method for creating data extraction definition information
Harding et al. Sequence-RTG: efficient and production-ready pattern mining in system log messages
US8271874B2 (en) Method and apparatus for locating and transforming data
CN112613290A (en) Document template generation method, device, equipment and storage medium
CN115168399B (en) Data processing method, device and equipment based on graphical interface and storage medium
JP5253115B2 (en) Program conversion device, program analysis device, program conversion method, program analysis method, and program
CN114385656A (en) Script detection method and device, computer equipment and storage medium
WO2022180815A1 (en) Information processing program, information processing method, and information processing device
JP2008046850A (en) Document type determination device, and document type determination program

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