CN112947992B - Code version management method and device - Google Patents

Code version management method and device Download PDF

Info

Publication number
CN112947992B
CN112947992B CN202110347402.9A CN202110347402A CN112947992B CN 112947992 B CN112947992 B CN 112947992B CN 202110347402 A CN202110347402 A CN 202110347402A CN 112947992 B CN112947992 B CN 112947992B
Authority
CN
China
Prior art keywords
code
information
version
engineering
construction
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.)
Active
Application number
CN202110347402.9A
Other languages
Chinese (zh)
Other versions
CN112947992A (en
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.)
CCB Finetech Co Ltd
Original Assignee
CCB Finetech 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 CCB Finetech Co Ltd filed Critical CCB Finetech Co Ltd
Priority to CN202110347402.9A priority Critical patent/CN112947992B/en
Publication of CN112947992A publication Critical patent/CN112947992A/en
Application granted granted Critical
Publication of CN112947992B publication Critical patent/CN112947992B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a method and a device for managing code versions, and relates to the technical field of code management. One embodiment of the method comprises the following steps: when constructing the code engineering, generating construction information of the code engineering, wherein the construction information comprises a version number of the code engineering and corresponding submitted content; saving the code engineering and the construction information thereof to a file server according to the version number of the code engineering; when the code rolling is needed, determining a version number to be rolled back according to the submitted content corresponding to the code engineering, and acquiring the code engineering to be rolled back from the file server according to the version number to roll back the code. The implementation mode can automatically record the code construction information, realize the visual management of the code version information of the production environment, facilitate the check of the code construction information, execute the operations such as code rollback by one key, avoid the complex process of manually executing the code rollback, save the manpower resources, reduce the code construction error rate and improve the operation and maintenance efficiency of the system.

Description

Code version management method and device
Technical Field
The present invention relates to the field of code management technologies, and in particular, to a method and apparatus for code version management.
Background
Software code is typically version managed using svn, which is a centralized server code version control system, or git, which is a distributed code version control system, code version information typically contains code tag (tag) descriptions, version implementation function or repair function descriptions, version build date, etc. information, when a code pushed to an online (i.e., production) environment has a problem, a code rollback operation needs to be performed, the basic flow of the code rollback operation is to find a commit time without a problem, rollback the code to a previous version, resubmit the code to a main branch, manually build the code, and upload to a server.
In the process of implementing the present invention, the inventor finds that at least the following problems exist in the prior art:
the code rollback operation flow in the production environment is complex, the code needs to be manually rolled back, and the code is reconstructed and deployed to a server; the code build information is difficult to view.
Disclosure of Invention
In view of the above, the embodiment of the invention provides a method and a device for code version management, which can automatically record code construction information, realize visual management of the code version information of a production environment, facilitate viewing of the code construction information, execute code rollback by one key, save manpower resources, reduce code construction error rate and improve system operation and maintenance efficiency.
To achieve the above object, according to one aspect of an embodiment of the present invention, there is provided a method of code version management.
A method of code version management, comprising: when constructing a code project, generating construction information of the code project, wherein the construction information comprises a version number of the code project and corresponding submitted content; storing the code engineering and the construction information thereof into a file server according to the version number of the code engineering; when the code rolling is needed, determining a version number to be rolled back according to the submitted content corresponding to the code engineering, and acquiring the code engineering to be rolled back from the file server according to the version number to roll back the code.
Optionally, before generating the build information of the code project, the method further includes: judging whether the code engineering is positioned in a distributed version control system code warehouse or not; if not, outputting prompt information.
Optionally, generating the build information of the code project includes: acquiring configuration information for generating construction information, wherein the configuration information comprises a construction time format and construction mode configuration of a code project; acquiring submitted content, construction branches and constructor information corresponding to the code engineering by calling an interface of a distributed version control system; generating the construction time and construction mode of the code engineering according to the configuration information; and packaging and integrating the submitted content, the construction branch, the constructor information, the construction time and the construction mode corresponding to the code engineering to generate the construction information of the code engineering.
Optionally, the building mode comprises local building and server building.
Optionally, the acquiring the submitted content corresponding to the code engineering by calling an interface of the distributed version control system includes: acquiring the submitted content corresponding to the code engineering by calling a query submitted history interface in a distributed version control system; the submission content includes a code hash value, a submission time, a submission description, branch information, a presenter name, and a presenter mailbox.
Optionally, the acquiring the submitted content corresponding to the code engineering by calling an interface of the distributed version control system includes: acquiring all branches of a code warehouse by calling a local branch interface of a distributed version control system, wherein each branch has current, name, submission and tag attributes; and acquiring branches of the code engineering construction from all branches.
Optionally, the acquiring the code engineering constructed branch from all branches includes: and obtaining branch content with true current attribute value from all branches as branches constructed by the code engineering.
Optionally, the step of obtaining the constructor information corresponding to the code engineering by calling an interface of the distributed version control system includes: acquiring configuration content of the distributed version control system by calling a configuration interface of the distributed version control system; and acquiring constructor information corresponding to the code engineering according to the configuration content.
Optionally, the configuration content includes location information of a configuration file of the distributed version control system and attribute configuration information of the distributed version control system; the location information comprises an installation configuration, a global configuration and a local engineering configuration; the attribute configuration information comprises a user name, a user mailbox and a position of a code project; the builder information includes a user name and a user mailbox.
Optionally, obtaining the constructor information corresponding to the code engineering according to the configuration content includes: performing transposition processing on the array corresponding to the position information; traversing the transposed position information array, and trying to find constructor information in the attribute configuration information; if the information of the constructor is found, returning the information of the constructor; otherwise, prompting the user to configure the constructor information.
Optionally, the method further comprises: version information management is carried out on the code engineering through an automatic operation and maintenance platform; the version information management includes version deployment management and role management.
Optionally, the version deployment management comprises uploading, auditing, publishing and rollback management of a version package corresponding to the code engineering; the role management comprises the addition, modification and deletion of the user roles; the version package includes build information for the code project.
Optionally, the upload management of the version package includes: reading the construction information of the code engineering from a version packet corresponding to the received code engineering, and storing the construction information into a temporary variable; carrying out hash operation on submitted content corresponding to the code engineering included in the construction information, renaming the version package according to a hash value obtained by the hash operation, and then updating the temporary variable; and storing the updated temporary variable into a database to carry out uploading management of the version package.
Optionally, the release management of the version package includes: pushing the version package passing the verification to a production environment server according to the version package release request, and updating the production time of the version package so as to carry out release management of the version package.
Optionally, determining the version number to be rolled back according to the submitted content corresponding to the code engineering includes: and searching the code engineering which is not problematic and is operated recently from the code engineering which is operated in the production environment according to the submitted content corresponding to the code engineering, and determining the version number corresponding to the searched code engineering as the version number to be rolled back.
According to another aspect of an embodiment of the present invention, an apparatus for code version management is provided.
An apparatus for code version management, comprising: the information generation module is used for generating construction information of the code engineering when the code engineering is constructed, wherein the construction information comprises a version number of the code engineering and corresponding submitted content; the information storage module is used for storing the code engineering and the construction information thereof into a file server according to the version number of the code engineering; and the code rolling module is used for determining a version number to be rolled back according to the submitted content corresponding to the code engineering when the code rolling is required, and acquiring the code engineering to be rolled back from the file server according to the version number so as to roll the code.
Optionally, the apparatus further includes a code judging module, configured to: judging whether the code engineering is positioned in a distributed version control system code warehouse or not; if not, outputting prompt information.
Optionally, the information generating module is further configured to: acquiring configuration information for generating construction information, wherein the configuration information comprises a construction time format and construction mode configuration of a code project; acquiring submitted content, construction branches and constructor information corresponding to the code engineering by calling an interface of a distributed version control system; generating the construction time and construction mode of the code engineering according to the configuration information; and packaging and integrating the submitted content, the construction branch, the constructor information, the construction time and the construction mode corresponding to the code engineering to generate the construction information of the code engineering.
Optionally, the building mode comprises local building and server building.
Optionally, the information generating module is further configured to: acquiring the submitted content corresponding to the code engineering by calling a query submitted history interface in a distributed version control system; the submission content includes a code hash value, a submission time, a submission description, branch information, a presenter name, and a presenter mailbox.
Optionally, the information generating module is further configured to: acquiring all branches of a code warehouse by calling a local branch interface of a distributed version control system, wherein each branch has current, name, submission and tag attributes; and acquiring branches of the code engineering construction from all branches.
Optionally, the information generating module is further configured to: and obtaining branch content with true current attribute value from all branches as branches constructed by the code engineering.
Optionally, the information generating module is further configured to: acquiring configuration content of the distributed version control system by calling a configuration interface of the distributed version control system; and acquiring constructor information corresponding to the code engineering according to the configuration content.
Optionally, the configuration content includes location information of a configuration file of the distributed version control system and attribute configuration information of the distributed version control system; the location information comprises an installation configuration, a global configuration and a local engineering configuration; the attribute configuration information comprises a user name, a user mailbox and a position of a code project; the builder information includes a user name and a user mailbox.
Optionally, the information generating module is further configured to: performing transposition processing on the array corresponding to the position information; traversing the transposed position information array, and trying to find constructor information in the attribute configuration information; if the information of the constructor is found, returning the information of the constructor; otherwise, prompting the user to configure the constructor information.
Optionally, the apparatus further comprises a version management module for: version information management is carried out on the code engineering through an automatic operation and maintenance platform; the version information management includes version deployment management and role management.
Optionally, the version deployment management comprises uploading, auditing, publishing and rollback management of a version package corresponding to the code engineering; the role management comprises the addition, modification and deletion of the user roles; the version package includes build information for the code project.
Optionally, the version management module is further configured to: reading the construction information of the code engineering from a version packet corresponding to the received code engineering, and storing the construction information into a temporary variable; carrying out hash operation on submitted content corresponding to the code engineering included in the construction information, renaming the version package according to a hash value obtained by the hash operation, and then updating the temporary variable; and storing the updated temporary variable into a database to carry out uploading management of the version package.
Optionally, the version management module is further configured to: pushing the version package passing the verification to a production environment server according to the version package release request, and updating the production time of the version package so as to carry out release management of the version package.
Optionally, the code rollback module is further configured to: and searching the code engineering which is not problematic and is operated recently from the code engineering which is operated in the production environment according to the submitted content corresponding to the code engineering, and determining the version number corresponding to the searched code engineering as the version number to be rolled back.
According to yet another aspect of an embodiment of the present invention, an electronic device for code version management is provided.
An electronic device for code version management, comprising: one or more processors; and the storage device is used for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors are enabled to realize the code version management method provided by the embodiment of the invention.
According to yet another aspect of an embodiment of the present invention, a computer-readable medium is provided.
A computer readable medium having stored thereon a computer program which when executed by a processor implements a method of code version management provided by an embodiment of the present invention.
One embodiment of the above invention has the following advantages or benefits: when a code project is constructed, generating construction information of the code project, wherein the construction information comprises a version number of the code project and corresponding submitted content; storing the code engineering and the construction information thereof into a file server according to the version number of the code engineering; when the code rolling is needed, determining a version number to be rolled according to the submitted content corresponding to the code engineering, acquiring the code engineering to be rolled from the file server according to the version number to carry out the technical means of the code rolling, automatically recording code construction information, realizing the visual management of the code version information of the production environment, facilitating the check of the code construction information, executing the operations such as the code rolling by one key, avoiding the complex process of manually executing the code rolling, saving human resources, reducing the code construction error rate and improving the operation and maintenance efficiency of the system.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of the main steps of a method of code version management according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a builder information retrieval process in accordance with an embodiment of the present invention;
FIG. 3 is a schematic diagram of a build information generation flow according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a build information file according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of a version information management interface according to an embodiment of the present invention;
FIG. 6 is a version detail interface schematic of an embodiment of the invention;
FIG. 7 is a schematic diagram of a role management interface in accordance with an embodiment of the present invention;
FIG. 8 is a diagram of a role-adding interface according to an embodiment of the present invention;
FIG. 9 is a schematic diagram of the main blocks of an apparatus for code version management according to an embodiment of the present invention;
FIG. 10 is an exemplary system architecture diagram in which embodiments of the present invention may be applied;
fig. 11 is a schematic diagram of a computer system suitable for use in implementing an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention will now be described with reference to the accompanying drawings, in which various details of the embodiments of the present invention are included to facilitate understanding, and are to be considered merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Currently, a git warehouse is used to manage code versions in most ways, so that a git tool is used in the version management system, the basic flow of a code rollback operation is to find a problem-free commit time, rollback the code to a previous version (generally using a git reset instruction), resubmit the code to a main branch, which is generally a master branch, manually construct the code and upload the code to a server, and the set of operation flow is complex and comprises the following specific contents:
(1) When the commit time of the code without the problem needs to be searched, if a developer commits the code each time and does not pay attention to normalized commit contents, the problem-free code can be searched more complicated;
(2) The rollback of the code can discard the code commit record after the instruction of the gitreset is used, and the code commit record can not be lost when the instruction of the git reset is used, but the code conflict needs to be solved;
(3) The code is reconstructed and uploaded to the server.
In the prior art, the production environment code version lacks a visual interface and operation, and the conventional operation is to label the code by using a git tag-a before the code is put on line, namely, the version put on line each time is a label, and the label is checked through the git tag to check the previous production environment code; the operation flow is complex when the codes are rolled back, the codes are manually rolled back, reconstructed and deployed to the server; the code construction information is difficult to view, such as no constructor information, construction time and the like.
The invention can realize automatic code version management, and automatically records the current construction information, including construction time, the last submitted information of the version (the has h value of the version, the submitted content description, version branches and the submitted person information), the construction branches and the code constructor information when executing code construction; the automatic operation and maintenance platform records the version package information on line each time, can display the production environment code version information, the visualized operations such as code rollback and the like, executes the code rollback by one key, has simple and convenient operation, reduces the code construction error rate and improves the operation and maintenance efficiency of the system.
Fig. 1 is a schematic diagram of main steps of a method for managing a code version according to an embodiment of the present invention, and as shown in fig. 1, the method for managing a code version according to an embodiment of the present invention mainly includes the following steps S101 to S103.
Step S101: when constructing the code engineering, generating construction information of the code engineering, wherein the construction information comprises a version number of the code engineering and corresponding submitted content; the front-end engineering code generally uses a module packer (weback or roller) tool to compile and output the project source code into an executable code.
According to one embodiment of the present invention, before generating the build information of the code engineering, the method further includes: judging whether the code engineering is positioned in a distributed version control system code warehouse; if not, outputting prompt information. When the plug-in unit runs, whether the code engineering is located in the git code warehouse or not can be judged, if the constructed code warehouse is not the git warehouse, the code does not have code branches, information and other contents are submitted, at the moment, the plug-in unit can throw prompt information to prompt a constructor to check and construct the code, if the code engineering is not located in the code warehouse, the plug-in unit can throw prompt information to prompt a user to upload the code engineering to the code warehouse, and if the code engineering is located in the git code warehouse, the plug-in unit continues to execute the code engineering downwards.
In an embodiment of the present invention, generating build information for a code project includes: acquiring configuration information for generating construction information, wherein the configuration information comprises construction time format and construction mode configuration of a code project; acquiring submitted content, construction branches and constructor information corresponding to code engineering by calling an interface of a distributed version control system; generating the construction time and construction mode of the code engineering according to the configuration information; packaging and integrating the submitted content, the construction branch, the constructor information, the construction time and the construction mode corresponding to the code engineering to generate construction information of the code engineering; the construction mode comprises local construction and server construction.
In the embodiment of the invention, the acquiring the submitted content corresponding to the code engineering by calling the interface of the distributed version control system comprises the following steps: acquiring submitted content corresponding to code engineering by calling a query submitted history interface in a distributed version control system; the commit content includes a code hash value, commit time, commit description, branch information, a commit person name, and a commit person mailbox. The plugin acquires the content of the latest information (commit) by calling a query submission history interface (log api) of the git, the log api returns a value as an object, and the object has a last attribute, and the last attribute contains the latest submission information, and is shown as an example return value information as follows:
the above shows the content format of code submission information (commit), wherein:
(1) The hash is a submitted information hash value and has uniqueness;
(2) date is code commit time;
(3) message is a code submission description;
(4) ref is the code branch information constructed, "HEAD- > dev" means that the dev branch is constructed;
(5) author_name is the code submitter name;
(6) author_email is a code submitter mailbox;
the last code submitting content in the construction can be recorded through the information, the submitting content in each version release can be clearly recorded, and when the production environment program has problems, the code submitting record without problems in the last time can be quickly found, so that the code rollback can be realized more quickly.
According to one embodiment of the present invention, the acquiring the submitted content corresponding to the code engineering by calling the interface of the distributed version control system includes: acquiring all branches of a code warehouse by calling a local branch interface of a distributed version control system, wherein each branch has current, name, submission and tag attributes; and acquiring the branch content with the current attribute value of true from all branches as branches of code engineering construction. The plug-in obtains the content of a build branch (branch) by calling the local branch interface (branch localmap) of git, the local branch interface (branch localmap) return value is an object, and there is a branch (branches) attribute in the object, and the branch attribute contains all branch information of the code warehouse, and an example of branch return value information is shown as follows:
the above shows a code branching information (branch) content format in which:
(1) The branch attribute contains all branch information, and the example code contains 2 branches, namely a dev branch and a master branch;
(2) Each branch contains 4 attributes, namely "current", "name", "commit" and "label", respectively, and if the value of "current" is true, this branch is the current branch of code engineering, that is, the construction branch, and in the above example code, the current branch is "dev". "name" is the name of the branch, "commit" is the hash value last submitted by the branch, and "table" is the last submitted information of the branch;
The return value of the local branch interface (branchLocalapi) is an object, and the object has a current attribute, and the current attribute is a branch constructed at this time, and is shown as an example of current return value information as follows:
current:'master'
the above indicates that the construction branch is a master branch, and the current attribute information is acquired to obtain the currently constructed branch.
According to another embodiment of the present invention, the obtaining builder information corresponding to the code engineering by calling an interface of the distributed version control system includes: acquiring configuration content of the distributed version control system by calling a configuration interface of the distributed version control system; and obtaining constructor information corresponding to the code engineering according to the configuration content. The configuration content comprises position information of a configuration file of the distributed version control system and attribute configuration information of the distributed version control system; the location information includes installation configuration, global configuration, and local engineering configuration; the attribute configuration information comprises a user name, a user mailbox and a code engineering position; the builder information includes a user name and a user mailbox. The plugin acquires and constructs the git configuration content by calling a git configuration interface (listConfigapi), a listConfigapi return value is an object, a file (file) attribute is included in the object, the file attribute includes location information of the git configuration file, another attribute in the listConfigapi return value is a value, and a value (value) attribute includes specific configuration content, and the following is an example of listConfigapi return value information:
The above shows the code git configuration information content format, wherein: file is the position of the configuration file, and the configuration files in the above example codes are in three places, namely ". Git/config", namely the local code engineering configuration; "/Users/xxx/. Gitcon fig" is the user globally configured git information; the "'/Library/development/Command LineTools/usr/share/gate-core/gate field'" is information configured by a user when installing a gate tool, the three file configuration information has priority, the local code project, global configuration and installation configuration are all configured by a mailbox (user.name) of the user, the code construction needs to be configured by using the local code project preferentially, then the global configuration is performed, finally the configuration when installing the gate tool is performed, the file attribute is an array, the sequence of array elements is the installation configuration, the global configuration and the local project configuration, the value attribute contains configuration information of the gate, such as a user name (user.name), a user mailbox (user.email), and a location where the code project is located (remote.origin).
According to still another embodiment of the present invention, obtaining builder information corresponding to a code project according to configuration content includes: performing transposition on the array corresponding to the position information; traversing the transposed position information array, and trying to find constructor information in the attribute configuration information; if the constructor information is found, returning constructor information; otherwise, prompting the user to configure the constructor information. Fig. 2 is a schematic diagram of a builder information acquisition flow according to an embodiment of the present invention, and according to the above, the builder information acquisition flow in this embodiment is shown in fig. 2, and mainly includes the following steps:
(1) Acquiring configuration content of the distributed version control system by calling a configuration interface of the distributed version control system; the configuration content comprises position information of a configuration file of the distributed version control system and attribute configuration information of the distributed version control system, and in the embodiment, the git configuration information is obtained;
(2) Performing transposition on the array corresponding to the position information; traversing the transposed position information array, and searching constructor information in attribute configuration information, wherein the invention carries out transposed processing on the array corresponding to the file attribute, namely, the array information of the file attribute is adjusted as follows: the local engineering configuration, the global configuration and the installation configuration circularly traverse array elements according to the transposed content (an array) of the file attribute, and find out whether the vulue attribute contains a user name and a user mailbox;
(3) If the constructor information is found, the constructor information is returned, namely if the user is obtained, the information is returned; otherwise, prompting the user to configure the constructor information.
According to the foregoing, that is, the construction information of the code engineering is generated, fig. 3 is a schematic diagram of a construction information generation flow according to an embodiment of the present invention, and as shown in fig. 3, the construction information generation flow mainly includes:
(1) Judging whether the code engineering is positioned in the git code warehouse, if not, outputting prompt information, and prompting a user to upload the code engineering to the git code warehouse in the embodiment of the invention;
(2) Acquiring configuration information for generating construction information, wherein the configuration information comprises construction time format and construction mode configuration of a code project; the number of plug-in configuration information developed by the invention is 3, the configuration information is respectively the file name (outputName) of the construction information, and the default file name is build-info. Json; constructing a time format (datformattype) of information, such as year, month, day, time, second, year, month, day, etc., and defaulting to 'yyyy-MM-dd hh: MM: ss'; the building method (building type) is 2, one is local building, the other is server building (remote), when local code engineering introduces the plug-in by using Jenkins and other tools, the building method (building type) is set to be local, namely local building, when the server builds, the server pulls the code of the substitute code warehouse, and the plug-in building method (building type) is set to be remote.
(3) Calling an interface of a distributed version control system to acquire submitted content, construction branches and constructor information corresponding to code engineering;
(4) And packaging and integrating the submitted content, the construction branch, the constructor information, the construction time and the construction mode corresponding to the code engineering to generate construction information of the code engineering.
Step S102: and storing the code engineering and the construction information thereof into a file server according to the version number of the code engineering. FIG. 4 is a schematic diagram of a construction information file according to an embodiment of the present invention, where, as shown in FIG. 4, the construction information file is output to a package file directory, and the content of the construction information is as follows:
in an embodiment of the present invention, further comprising: version information management is carried out on the code engineering through an automatic operation and maintenance platform; version information management includes version deployment management and role management. FIG. 5 is a schematic diagram of a version information management interface in an embodiment of the present invention, where, as shown in FIG. 5, the layout of the version information management interface is a left-right two-column layout, and the left-side column is a menu column, and is mainly divided into two parts, namely, "version deployment" and "role management", where the "version deployment" implements a visual operation code version, and the "role management" implements operations such as user right addition and modification of the system, and the right side of the interface is a main operation area, where the main operation area has a breadcrumbs navigation column, so that a corresponding page can be quickly reached; the main operation area also has a search area, which can quickly filter data according to related information, such as which version packages the constructor has constructed according to the constructor name.
In the embodiment of the invention, version deployment management comprises uploading, auditing, publishing and rollback management of version packages corresponding to code engineering; character management includes the addition, modification and deletion of user characters; the version package includes build information for the code project. The uploading management of the version package comprises the following steps: reading the construction information of the code engineering from the version package corresponding to the received code engineering, and storing the construction information into a temporary variable; carrying out hash operation on submitted content corresponding to code engineering included in the construction information, renaming a version packet according to a hash value obtained by the hash operation, and then updating a temporary variable; and storing the updated temporary variable into a database to carry out uploading management of the version package. The release management of the version package comprises the following steps: pushing the version package passing the verification to a production environment server according to the version package release request, and updating the production time of the version package so as to carry out release management of the version package.
Step S103: when the code rolling is needed, determining a version number to be rolled back according to the submitted content corresponding to the code engineering, and acquiring the code engineering to be rolled back from the file server according to the version number to roll back the code.
In an embodiment of the present invention, determining a version number to be rolled back according to the submitted content corresponding to the code engineering includes: and searching the code engineering which is not problematic and is operated recently from the code engineering which is operated in the production environment according to the submitted content corresponding to the code engineering, and determining the version number corresponding to the searched code engineering as the version number to be rolled back.
The details of version deployment management and role management are as follows:
1. version deployment management
(1) The method comprises the steps of uploading a version package, clicking a version deployment management menu on a version information management interface, clicking a version package uploading button at the upper right corner of the interface, and uploading the version package constructed by a local or remote server to a file server by clicking the version package uploading button, wherein construction information exists in the version package in the form of json files;
(2) Version package auditing, the version package is audited by a project group leader or a colleague with higher authority before being deployed in a production environment, when the project group leader checks the details of the version package, clicking a detail button in an operation column of each row in a table of an interface, and fig. 6 is a schematic diagram of the version detail interface in the embodiment of the invention, as shown in fig. 6, when version package information is correct, the group leader can audit the version package, and if the version package information has a problem, the group leader can contact a constructor for constructing the version, and the requirement is that: the auditing, publishing and rollback in the interface are processed by talents above the project group leader with authority, the development engineer has no authority to operate, and all persons capable of logging in the system can process the version package uploading and detail buttons;
(3) Version package release, for the audit version package after the project group leader, when the project production date is reached, the project group leader can click on a release button to push the version package to a production environment server, update the production time of the realization version of the version and realize the deployment work of the version package;
(4) And for the version package after casting, if problems occur in the production environment and engineers cannot quickly solve, in order to avoid larger losses to enterprises and users, the project group leader can push the version without problems in the previous production environment to the production environment server, and at the moment, the project group leader clicks a roll-back button in the corresponding version operation column, and the program pushes the version package of the version to the production environment server. This process eliminates the need for engineers to manually rollback code, reconstruct version packages, and deploy to the production environment. The system rollback efficiency is high, and the operation and maintenance cost is low;
2. Role management
FIG. 7 is a schematic diagram of a role management interface in an embodiment of the present invention, in which role management can implement addition of system roles, role editing and deletion of roles, and as shown in FIG. 7, there is a search area on the interface, and users can be quickly filtered according to related information, and it is to be noted that only a super administrator can see the menu for role management, that is, only the super administrator has related operation rights.
(1) FIG. 8 is a schematic diagram of a character addition interface according to an embodiment of the present invention, and a character can be added by clicking a "new" button on the upper right corner of the character management interface, and details are shown in FIG. 8.
(2) When the user permission changes, the user role needs to be maintained, and the user role can be modified by clicking an edit button of each row of the form in the interface, so that the modified page is similar to the newly added page.
(3) And deleting the user roles, wherein when the user leaves the office or the user authority is reduced to the condition that the version package cannot be audited and released, the user needs to be deleted, and the deletion of the corresponding user authority is ensured. At this time, clicking the "delete" button on the interface where the user is located.
Fig. 9 is a schematic diagram of main modules of an apparatus for code version management according to an embodiment of the present invention, and as shown in fig. 9, an apparatus 900 for code version management according to an embodiment of the present invention mainly includes an information generating module 901, an information saving module 902, and a code rollback module 903.
The information generating module 901 is configured to generate, when a code project is constructed, construction information of the code project, where the construction information includes a version number of the code project and a corresponding submitted content;
the information saving module 902 is configured to save the code engineering and its construction information to the file server according to the version number of the code engineering;
the code rollback module 903 is configured to determine, when code rollback is required, a version number to be rolled back according to a submitted content corresponding to the code engineering, and obtain, according to the version number, the code engineering to be rolled back from the file server to perform the code rollback.
According to an embodiment of the present invention, the apparatus 900 further includes a code determination module (not shown in the figure) for: judging whether the code engineering is positioned in a distributed version control system code warehouse; if not, outputting prompt information.
In an embodiment of the present invention, the information generating module 901 is further configured to: acquiring configuration information for generating construction information, wherein the configuration information comprises construction time format and construction mode configuration of a code project; acquiring submitted content, construction branches and constructor information corresponding to code engineering by calling an interface of a distributed version control system; generating the construction time and construction mode of the code engineering according to the configuration information; and packaging and integrating the submitted content, the construction branch, the constructor information, the construction time and the construction mode corresponding to the code engineering to generate construction information of the code engineering.
In an embodiment of the invention, the building mode comprises local building and server building.
In an embodiment of the present invention, the information generating module 901 is further configured to: acquiring submitted content corresponding to code engineering by calling a query submitted history interface in a distributed version control system; the commit content includes a code hash value, commit time, commit description, branch information, a commit person name, and a commit person mailbox.
In an embodiment of the present invention, the information generating module 901 is further configured to: acquiring all branches of a code warehouse by calling a local branch interface of a distributed version control system, wherein each branch has current, name, submission and tag attributes; the branches of the code engineering construction are obtained from all branches.
In an embodiment of the present invention, the information generating module 901 is further configured to: and acquiring branch content with true current attribute value from all branches as branches of code engineering construction.
In an embodiment of the present invention, the information generating module 901 is further configured to: acquiring configuration content of the distributed version control system by calling a configuration interface of the distributed version control system; and obtaining constructor information corresponding to the code engineering according to the configuration content.
According to another embodiment of the present invention, the configuration content includes location information of a configuration file of the distributed version control system and attribute configuration information of the distributed version control system; the location information includes installation configuration, global configuration, and local engineering configuration; the attribute configuration information comprises a user name, a user mailbox and a code engineering position; the builder information includes a user name and a user mailbox.
In an embodiment of the present invention, the information generating module 901 is further configured to: performing transposition on the array corresponding to the position information; traversing the transposed position information array, and trying to find constructor information in the attribute configuration information; if the constructor information is found, returning constructor information; otherwise, prompting the user to configure the constructor information.
According to a further embodiment of the invention, the apparatus further comprises a version management module (not shown in the figure) for: version information management is carried out on the code engineering through an automatic operation and maintenance platform; version information management includes version deployment management and role management.
In the embodiment of the invention, version deployment management comprises uploading, auditing, publishing and rollback management of version packages corresponding to code engineering; character management includes the addition, modification and deletion of user characters; the version package includes build information for the code project.
In an embodiment of the present invention, the version management module is further configured to: reading the construction information of the code engineering from the version package corresponding to the received code engineering, and storing the construction information into a temporary variable; carrying out hash operation on submitted content corresponding to code engineering included in the construction information, renaming a version packet according to a hash value obtained by the hash operation, and then updating a temporary variable; and storing the updated temporary variable into a database to carry out uploading management of the version package.
In an embodiment of the present invention, the version management module is further configured to: pushing the version package passing the verification to a production environment server according to the version package release request, and updating the production time of the version package so as to carry out release management of the version package.
According to yet another embodiment of the present invention, the code rollback module 903 is further configured to: and searching the code engineering which is not problematic and is operated recently from the code engineering which is operated in the production environment according to the submitted content corresponding to the code engineering, and determining the version number corresponding to the searched code engineering as the version number to be rolled back.
Fig. 10 illustrates an exemplary system architecture 1000 of a device or method of code version management to which embodiments of the present invention may be applied.
As shown in fig. 10, a system architecture 1000 may include terminal devices 1001, 1002, 1003, a network 1004, and a server 1005. The network 1004 serves as a medium for providing a communication link between the terminal apparatuses 1001, 1002, 1003 and the server 1005. The network 1004 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
A user can interact with a server 1005 via a network 1004 using terminal apparatuses 1001, 1002, 1003 to receive or transmit messages or the like. Various communication client applications such as an operation class application, a code management tool, a programming class application, etc. (only examples) may be installed on the terminal devices 1001, 1002, 1003.
The terminal devices 1001, 1002, 1003 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smartphones, tablets, laptop and desktop computers, and the like.
The server 1005 may be a server providing various services, such as a background management server (merely an example) providing support for a code management class website browsed by the user using the terminal apparatuses 1001, 1002, 1003. The background management server may analyze and process the received data such as the version rollback request, and feed back the processing result (e.g., the code version number—only an example) to the terminal device.
It should be noted that, the method for managing a code version provided in the embodiment of the present invention is generally executed by the server 1005, and accordingly, the device for managing a code version is generally disposed in the server 1005.
It should be understood that the number of terminal devices, networks and servers in fig. 10 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 11, there is illustrated a schematic diagram of a computer system 1100 suitable for use in implementing a terminal device or server in accordance with an embodiment of the present invention. The terminal device or server shown in fig. 11 is only an example, and should not impose any limitation on the functions and scope of use of the embodiments of the present invention.
As shown in fig. 11, the computer system 1100 includes a Central Processing Unit (CPU) 1101, which can execute various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 1102 or a program loaded from a storage section 1108 into a Random Access Memory (RAM) 1103. In the RAM1103, various programs and data required for the operation of the system 1100 are also stored. The CPU1101, ROM1102, and RAM1103 are connected to each other by a bus 1104. An input/output (I/O) interface 1105 is also connected to bus 1104.
The following components are connected to the I/O interface 1105: an input section 1106 including a keyboard, a mouse, and the like; an output portion 1107 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, a speaker, and the like; a storage section 1108 including a hard disk or the like; and a communication section 1109 including a network interface card such as a LAN card, a modem, and the like. The communication section 1109 performs communication processing via a network such as the internet. The drive 1110 is also connected to the I/O interface 1105 as needed. Removable media 1111, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like, is installed as needed in drive 1110, so that a computer program read therefrom is installed as needed in storage section 1108.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such an embodiment, the computer program can be downloaded and installed from a network via the communication portion 1109, and/or installed from the removable media 1111. The above-described functions defined in the system of the present invention are performed when the computer program is executed by a Central Processing Unit (CPU) 1101.
The computer readable medium shown in the present invention may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units or modules involved in the embodiments of the present invention may be implemented in software or in hardware. The described units or modules may also be provided in a processor, for example, as: a processor comprises an information generation module, an information storage module and a code rollback module. The names of these units or modules do not limit the units or modules themselves in some cases, and for example, the information saving module may also be described as "a module for saving the code project and its construction information to a file server according to the version number of the code project".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be present alone without being fitted into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to include: when constructing a code project, generating construction information of the code project, wherein the construction information comprises a version number of the code project and corresponding submitted content; storing the code engineering and the construction information thereof into a file server according to the version number of the code engineering; when the code rolling is needed, determining a version number to be rolled back according to the submitted content corresponding to the code engineering, and acquiring the code engineering to be rolled back from the file server according to the version number to roll back the code.
According to the technical scheme of the embodiment of the invention, when the code engineering is constructed, construction information of the code engineering is generated, and the construction information comprises a version number of the code engineering and corresponding submitted content; storing the code engineering and the construction information thereof into a file server according to the version number of the code engineering; when the code rolling is needed, the version number to be rolled is determined according to the submitted content corresponding to the code engineering, and the code engineering to be rolled is acquired from the file server according to the version number so as to carry out the technical means of the code rolling, so that the code construction information is automatically recorded, the visual management of the code version information of the production environment is realized, the viewing of the code construction information is convenient, the operations such as the code rolling are carried out by one key, the complex flow of manual code rolling is avoided, the manpower resource is saved, the code construction error rate is reduced, and the operation and maintenance efficiency of the system is improved.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives can occur depending upon design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (17)

1. A method of code version management, comprising:
when constructing a code project, generating construction information of the code project, wherein the construction information comprises a version number of the code project and corresponding submitted content;
storing the code engineering and the construction information thereof into a file server according to the version number of the code engineering, reading the construction information of the code engineering from a version packet corresponding to the code engineering received by the file server, and storing the construction information into a temporary variable; carrying out hash operation on submitted content corresponding to the code engineering included in the construction information, renaming the version package according to a hash value obtained by the hash operation, and then updating the temporary variable; storing the updated temporary variable into a database to carry out uploading management of the version package; after the uploaded version package passes the verification, pushing the verified version package to a production environment server according to the version package release request; the version package comprises construction information of the code engineering;
When the code rolling is needed, determining a version number to be rolled back according to the submitted content corresponding to the code engineering, and acquiring the code engineering to be rolled back from the file server according to the version number to roll back the code.
2. The method of claim 1, further comprising, prior to generating build information for the code project:
judging whether the code engineering is positioned in a distributed version control system code warehouse or not;
if not, outputting prompt information.
3. The method of claim 1, wherein generating build information for the code project comprises:
acquiring configuration information for generating construction information, wherein the configuration information comprises a construction time format and construction mode configuration of a code project;
acquiring submitted content, construction branches and constructor information corresponding to the code engineering by calling an interface of a distributed version control system; generating the construction time and construction mode of the code engineering according to the configuration information;
and packaging and integrating the submitted content, the construction branch, the constructor information, the construction time and the construction mode corresponding to the code engineering to generate the construction information of the code engineering.
4. A method according to claim 3, wherein the building means comprises a local building and a server building.
5. The method of claim 3, wherein retrieving the code engineering corresponding submission by invoking an interface of a distributed version control system comprises:
acquiring the submitted content corresponding to the code engineering by calling a query submitted history interface in a distributed version control system; the submission content includes a code hash value, a submission time, a submission description, branch information, a presenter name, and a presenter mailbox.
6. The method of claim 3, wherein retrieving the code engineering corresponding submission by invoking an interface of a distributed version control system comprises:
acquiring all branches of a code warehouse by calling a local branch interface of a distributed version control system, wherein each branch has current, name, submission and tag attributes;
and acquiring branches of the code engineering construction from all branches.
7. The method of claim 6, wherein obtaining the code engineered branches from the all branches comprises:
And obtaining branch content with true current attribute value from all branches as branches constructed by the code engineering.
8. The method of claim 3, wherein obtaining constructor information corresponding to the code project by invoking an interface of a distributed version control system comprises:
acquiring configuration content of the distributed version control system by calling a configuration interface of the distributed version control system;
and acquiring constructor information corresponding to the code engineering according to the configuration content.
9. The method of claim 8, wherein the configuration content includes location information of a configuration file of the distributed version control system and attribute configuration information of the distributed version control system; the location information comprises an installation configuration, a global configuration and a local engineering configuration; the attribute configuration information comprises a user name, a user mailbox and a position of a code project; the builder information includes a user name and a user mailbox.
10. The method of claim 9, wherein obtaining builder information corresponding to the code project from the configuration content comprises:
Performing transposition processing on the array corresponding to the position information;
traversing the transposed position information array, and trying to find constructor information in the attribute configuration information;
if the information of the constructor is found, returning the information of the constructor; otherwise, prompting the user to configure the constructor information.
11. The method according to claim 1, wherein the method further comprises: and performing role management on the code engineering through an automatic operation and maintenance platform.
12. The method of claim 11, wherein the role management includes the addition, modification and deletion of user roles; the version package includes build information for the code project.
13. The method according to claim 1, wherein the method further comprises:
after the version package passing the verification is pushed to the production environment server, the production time of the version package is updated.
14. The method of claim 1 or 12, wherein determining the version number to roll back based on the submitted content corresponding to the code project comprises:
and searching the code engineering which is not problematic and is operated recently from the code engineering which is operated in the production environment according to the submitted content corresponding to the code engineering, and determining the version number corresponding to the searched code engineering as the version number to be rolled back.
15. An apparatus for code version management, comprising:
the information generation module is used for generating construction information of the code engineering when the code engineering is constructed, wherein the construction information comprises a version number of the code engineering and corresponding submitted content;
the information storage module is used for storing the code engineering and the construction information thereof into a file server according to the version number of the code engineering;
version management module for: reading the construction information of the code engineering from a version packet corresponding to the code engineering received by a file server, and storing the construction information into a temporary variable; carrying out hash operation on submitted content corresponding to the code engineering included in the construction information, renaming the version package according to a hash value obtained by the hash operation, and then updating the temporary variable; storing the updated temporary variable into a database to carry out uploading management of the version package; after the uploaded version package passes the verification, pushing the verified version package to a production environment server according to the version package release request; the version package comprises construction information of the code engineering;
and the code rolling module is used for determining a version number to be rolled back according to the submitted content corresponding to the code engineering when the code rolling is required, and acquiring the code engineering to be rolled back from the file server according to the version number so as to roll the code.
16. An electronic device for code version management, comprising:
one or more processors;
storage means for storing one or more programs,
when executed by the one or more processors, causes the one or more processors to implement the method of any of claims 1-14.
17. A computer readable medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the method according to any of claims 1-14.
CN202110347402.9A 2021-03-31 2021-03-31 Code version management method and device Active CN112947992B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110347402.9A CN112947992B (en) 2021-03-31 2021-03-31 Code version management method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110347402.9A CN112947992B (en) 2021-03-31 2021-03-31 Code version management method and device

Publications (2)

Publication Number Publication Date
CN112947992A CN112947992A (en) 2021-06-11
CN112947992B true CN112947992B (en) 2023-10-27

Family

ID=76231366

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110347402.9A Active CN112947992B (en) 2021-03-31 2021-03-31 Code version management method and device

Country Status (1)

Country Link
CN (1) CN112947992B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113467781B (en) * 2021-06-30 2023-02-21 建信金融科技有限责任公司 Method, device and equipment for determining redundant file
CN113486327A (en) * 2021-07-26 2021-10-08 上海中通吉网络技术有限公司 Code warehouse management method and system based on gitlab
CN118034777B (en) * 2024-04-11 2024-06-25 四川天邑康和通信股份有限公司 FTTR-based log management and version control method, FTTR-based log management and version control device, FTTR-based log management and version control equipment and medium

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110321254A (en) * 2019-07-09 2019-10-11 西安点告网络科技有限公司 Software version rollback method, device, server and storage medium

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110321254A (en) * 2019-07-09 2019-10-11 西安点告网络科技有限公司 Software version rollback method, device, server and storage medium

Also Published As

Publication number Publication date
CN112947992A (en) 2021-06-11

Similar Documents

Publication Publication Date Title
US11740891B2 (en) Providing access to a hybrid application offline
EP3707615B1 (en) Violation resolution in client synchronization
CN112947992B (en) Code version management method and device
US11516288B2 (en) Synchronized content library
JP6463393B2 (en) Tenant data recovery across tenant migration
KR101376916B1 (en) Techniques to perform gradual upgrades
US20140280463A1 (en) Implementing a consistent ordering of operations in collaborative editing of shared content items
US20230101774A1 (en) Techniques for performing clipboard-to-file paste operations
CN112765102B (en) File system management method and device
CN111984686A (en) Data processing method and device
CN113760600B (en) Database backup method, database restoration method and related devices
US20230039744A1 (en) Automated creation and deployment of websites
CN110543520B (en) Data migration method and device
CN113742321A (en) Data updating method and device
CN110874302A (en) Method and device for determining buried point configuration information
CN111177183B (en) Method and device for generating database access statement

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
GR01 Patent grant
GR01 Patent grant