CN116451272A - Git-based code library control method and device and electronic equipment - Google Patents

Git-based code library control method and device and electronic equipment Download PDF

Info

Publication number
CN116451272A
CN116451272A CN202310374716.7A CN202310374716A CN116451272A CN 116451272 A CN116451272 A CN 116451272A CN 202310374716 A CN202310374716 A CN 202310374716A CN 116451272 A CN116451272 A CN 116451272A
Authority
CN
China
Prior art keywords
directory
protection
change
git
target branch
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
CN202310374716.7A
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.)
Beijing Dajia Internet Information Technology Co Ltd
Original Assignee
Beijing Dajia Internet Information Technology 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 Beijing Dajia Internet Information Technology Co Ltd filed Critical Beijing Dajia Internet Information Technology Co Ltd
Priority to CN202310374716.7A priority Critical patent/CN116451272A/en
Publication of CN116451272A publication Critical patent/CN116451272A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/62Protecting access to data via a platform, e.g. using keys or access control rules
    • G06F21/6218Protecting access to data via a platform, e.g. using keys or access control rules to a system of files or objects, e.g. local or distributed file system or database
    • 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/901Indexing; Data structures therefor; Storage structures
    • G06F16/9017Indexing; Data structures therefor; Storage structures using directory or table look-up
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2221/00Indexing scheme relating to security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F2221/21Indexing scheme relating to G06F21/00 and subgroups addressing additional information or applications relating to security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F2221/2141Access rights, e.g. capability lists, access control lists, access tables, access matrices
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Software Systems (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Bioethics (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Hardware Design (AREA)
  • General Health & Medical Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Data Mining & Analysis (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The disclosure relates to a Git-based code library control method, a device and electronic equipment. Wherein the method comprises the following steps: under the condition that the pushing operation of a user is detected, acquiring the pushing operation through a hook function of a server side; wherein the push operation includes a change operation for a target branch, the target branch including at least one directory; intercepting the pushing operation under the condition that the directory in the target branch meets a preset directory protection condition; the preset target protection directory condition is used for indicating a directory which cannot be changed by the user. By adopting the Git-based code base control method provided by the embodiment of the disclosure, the directory-level authority refinement control of the code base can be realized on the basis of Git.

Description

Git-based code library control method and device and electronic equipment
Technical Field
The disclosure relates to the technical field of computers, and in particular relates to a method, a device and electronic equipment for controlling a code library based on Git.
Background
In the related art, code data version control is generally implemented through Git (The stupid content tracker, fool content tracker), and Git does not support authority control at the code library directory level. However, for some large-scale items or items migrated from SVN (subversion) to Git, the directory files owned by the code library are usually more, and how to implement authority control of the code library directory level on the basis of Git has become a problem to be solved.
Disclosure of Invention
The disclosure provides a method, a device and an electronic device for controlling a code base based on Git, so as to at least solve the problem that the authority control of the code base directory level cannot be realized on the basis of Git in the related technology. The technical scheme of the present disclosure is as follows:
according to a first aspect of an embodiment of the present disclosure, there is provided a method for controlling a Git-based code library, including:
under the condition that the pushing operation of a user is detected, acquiring the pushing operation through a hook function of a server side; wherein the push operation includes a change operation for a target branch, the target branch including at least one directory;
intercepting the pushing operation under the condition that the directory in the target branch meets a preset directory protection condition; the preset target protection directory condition is used for indicating a directory which cannot be changed by the user.
In one possible implementation, the preset directory protection condition includes a protection directory, and the protection directory is one or more.
In a possible implementation manner, the intercepting the pushing operation in a case that the directory in the target branch meets a preset directory protection condition includes:
determining whether the directory in the target branch includes at least one of the protection directories;
in the event that the directory in the target branch includes at least one of the protection directories, the push operation is intercepted.
In a possible implementation manner, in a case that the directory in the target branch includes at least one protection directory, intercepting the push operation includes:
acquiring change directory information of the push operation under the condition that the directory in the target branch comprises at least one protection directory; wherein the change catalog information comprises at least one change catalog for carrying out change operation;
determining whether the change directory includes at least one of the protection directories;
and intercepting the pushing operation in the case that the change directory comprises at least one protection directory.
In a possible implementation manner, the determining whether the change directory includes at least one protection directory includes:
placing the change catalog information in a temporary catalog; wherein the temporary directory is a directory isolated from the change directory information;
determining in the temporary directory whether the change directory includes at least one of the protection directories.
In a possible implementation manner, the determining, in the temporary directory, whether the change directory includes at least one protection directory includes:
calling a Gitlab in the temporary directory to determine whether the change directory includes at least one of the protection directories.
In a possible implementation manner, in a case that the change directory includes at least one protection directory, after intercepting the push operation, the method further includes:
and deleting the temporary directory.
According to a second aspect of the embodiments of the present disclosure, there is provided a Git-based code library control device, including:
the operation acquisition module is configured to acquire pushing operation through a hook function of a server side under the condition that the pushing operation of a user is detected; wherein the push operation includes a change operation for a target branch, the target branch including at least one directory;
an operation interception module configured to intercept the push operation if the directory in the target branch satisfies a preset directory protection condition; the preset target protection directory condition is used for indicating a directory which cannot be changed by the user.
In one possible implementation, the preset directory protection condition includes a protection directory, and the protection directory is one or more.
In one possible implementation manner, the operation interception module includes:
a protection directory determining unit configured to determine whether the directory in the target branch includes at least one of the protection directories;
an operation intercepting unit configured to intercept the push operation in case the directory in the target branch comprises at least one of the protection directories.
In one possible embodiment, the operation interception unit includes:
an information acquisition subunit configured to acquire, in a case where the directory in the target branch includes at least one of the protection directories, changed directory information of the push operation; wherein the change catalog information comprises at least one change catalog for carrying out change operation;
a protection directory determining subunit configured to determine whether the change directory includes at least one of the protection directories;
an operation interception subunit configured to intercept the push operation if the change directory includes at least one of the protection directories.
In a possible implementation manner, the protection directory determining subunit is specifically configured to:
placing the change catalog information in a temporary catalog; wherein the temporary directory is a directory isolated from the change directory information;
determining in the temporary directory whether the change directory includes at least one of the protection directories.
In a possible implementation manner, the protection directory determining subunit is specifically further configured to:
calling a Gitlab in the temporary directory to determine whether the change directory includes at least one of the protection directories.
In one possible embodiment, the apparatus further comprises:
and the catalog deleting module is configured to delete the temporary catalog.
According to a third aspect of embodiments of the present disclosure, there is provided an electronic device, comprising:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to execute the instructions to implement a Git-based code library control method as claimed in any one of the first aspects.
According to a fourth aspect of embodiments of the present disclosure, there is provided a computer readable storage medium, which when executed by a processor of an electronic device, causes the electronic device to perform the Git-based code library control method as claimed in any one of the first aspects.
According to a fifth aspect of embodiments of the present disclosure, there is provided a computer program product comprising a computer program which, when executed by a processor, implements the Git-based code library control method of any one of the first aspects.
The technical scheme provided by the embodiment of the disclosure at least brings the following beneficial effects:
in the embodiment of the disclosure, under the condition that a pushing operation of a user is detected, the pushing operation is obtained through a hook function of a server side, wherein the pushing operation comprises a change operation aiming at a target branch, and the target branch comprises at least one directory; then, under the condition that the directory in the target branch meets the preset directory protection condition, the pushing operation is intercepted, wherein the preset target protection directory condition is used for indicating the directory which cannot be changed by the user. In this way, the characteristic of the hook function at the server end can be utilized to define the protection directory condition, and the push operation that the user changes the directory of the target branch but the user does not have the change authority of the directory is intercepted. Therefore, the authority refinement control of the directory level of the code library can be realized on the basis of Git, and the limitation in the related technology is solved; meanwhile, the safety of codes in the code library can be improved.
Moreover, the method provided by the embodiment of the disclosure has universality, can be used only by simple configuration, and has low cost.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the disclosure and together with the description, serve to explain the principles of the disclosure and do not constitute an undue limitation on the disclosure.
FIG. 1 is a flowchart illustrating a Git-based code library control method according to an example embodiment.
FIG. 2 is a diagram illustrating a relationship of permissions between a directory and users according to an exemplary embodiment.
FIG. 3 is a flowchart illustrating another Git-based code library control method according to an example embodiment.
FIG. 4 is a block diagram illustrating a Git-based code library control device according to an example embodiment.
Fig. 5 is a block diagram of an electronic device, according to an example embodiment.
Detailed Description
In order to enable those skilled in the art to better understand the technical solutions of the present disclosure, the technical solutions of the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.
It should be noted that the terms "first," "second," and the like in the description and claims of the present disclosure and in the foregoing figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the disclosure described herein may be capable of operation in sequences other than those illustrated or described herein. The implementations described in the following exemplary examples are not representative of all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with some aspects of the present disclosure as detailed in the accompanying claims.
The following describes in detail a method, an apparatus, and an electronic device for controlling a Git-based code library according to an embodiment of the present disclosure with reference to the accompanying drawings.
FIG. 1 is a flowchart illustrating a Git-based code library control method according to an example embodiment. As shown in FIG. 1, the Git-based code library control method may include the following steps.
In step S101, in the case where the pushing operation of the user is detected, the pushing operation is acquired by the hook function of the server side.
Wherein the push operation includes a change operation for a target branch, the target branch including at least one directory.
In the embodiment of the disclosure, after a user performs a change operation on a certain branch (i.e., a target branch) of a code base, the change operation on the branch may be pushed to a server by a push operation. The server side can periodically or in real time detect whether a pushing operation is received, and if the pushing operation of the user is detected, the pushing operation can be acquired through a hook before the pushing operation of the user is received. It can be understood that obtaining the push operation by the hook function of the server may also be understood as temporarily intercepting the push operation.
In step S102, in the case where the directory in the target branch satisfies the preset directory protection condition, the push operation is intercepted.
The preset target protection directory condition is used for indicating a directory which cannot be changed by a user. It will be appreciated that the aforementioned user may be the only user in step 101 described above, or may also include other users.
In the embodiment of the present disclosure, after a push operation is obtained by a hook function of a server side in a case where a push operation of a user is detected, a directory under a target branch in the push operation may be obtained, and illustratively, all directories under the target branch may be obtained. Then, the directory under the target branch may be compared with a preset directory protection condition to determine whether the directory under the target branch meets the preset protection directory condition, that is, whether the directory under the target branch includes a directory in which the user pushing the pushing operation cannot execute the changing operation, that is, whether the user has permission to change the directory under the target branch. If the directory in the target branch meets the preset target protection condition, for example, at least one directory under the target branch is a directory meeting the preset directory protection condition, the directory under the target branch can be considered to include a directory in which the user pushing the pushing operation cannot perform the changing operation, that is, the user does not have the authority to change the directory under the target branch, and at this time, the pushing operation can be intercepted. Otherwise, the pushing operation can be normally pushed to the server. It will be appreciated that after determining whether the directory in the target branch meets the preset directory protection condition by the hook function, if the preset directory protection condition is met, the directory may be output as a non-zero value, or vice versa. Therefore, the characteristics of the hook function of the server can be utilized to define the condition of the protection directory, detection and interception are carried out before the change operation is applied, and push operation interception is carried out under the condition that the change of the protection directory is detected.
In the embodiment of the disclosure, under the condition that a pushing operation of a user is detected, the pushing operation is obtained through a hook function of a server side, wherein the pushing operation comprises a change operation aiming at a target branch, and the target branch comprises at least one directory; then, under the condition that the directory in the target branch meets the preset directory protection condition, the pushing operation is intercepted, wherein the preset target protection directory condition is used for indicating the directory which cannot be changed by the user. In this way, the characteristic of the hook function at the server end can be utilized to define the protection directory condition, and the push operation that the user changes the directory of the target branch but the user does not have the change authority of the directory is intercepted. Therefore, the authority refinement control of the directory level of the code library can be realized on the basis of Git, and the limitation in the related technology is solved; meanwhile, the safety of codes in the code library can be improved.
Moreover, the method provided by the embodiment of the disclosure has universality, can be used only by simple configuration, and has low cost.
In one possible implementation, the preset directory protection condition may include protecting the directory, the protecting the directory being one or more. Illustratively, the protection directory may be such that all users cannot perform the change operation; or, a user identifier with changing authority can be added to the protection catalog so as to limit that only part of users can change the protection catalog; or, a user identifier without changing authority may be added to the protection directory, so as to limit that only part of users cannot change the protection directory. Taking fig. 2 as an example, fig. 2 shows a permission relationship between a directory and users, as shown in fig. 2, a code repository P in fig. 2 represents a code library, each team in fig. 2 may include one or more users, and a directory X may be set for a team a as a protection directory, that is, only the user of the team a has permission to change the directory X; similarly, the catalog Y can be set for team B as a protection catalog, that is, only the user of team B has the right to change the catalog Y; for the catalogue Z, belonging to public content, the possible scope of action is smaller, the frequency of modification is higher and the importance degree is not high, if the request for merging is required to be submitted each time, and then the code review approval is required, the whole flow and efficiency are reduced, no additional authority control is carried out on the file Z, the team A, B can directly push to submit and modify, the research and development delivery efficiency under partial scenes is improved, or only the team B can be set to have the authority for carrying out the change operation on the catalogue Z, or other teams (including the team B) except the team A can also be set to have the authority for carrying out the change operation on the catalogue Z; the directory which does not have the change authority is only read-only and can not be written; all teams such as team A and team B can read the downloaded project code warehouse P normally, all catalogs and file reading operations are not limited, association relations among different catalogs can be obtained, and team cooperation is facilitated; . Therefore, whether the user changes the authority of the directory in the target branch can be better and more accurately determined, so that the accuracy of intercepting pushing operation is improved, dangerous operations such as code tampering and error changing are prevented, and the code safety and the code quality are ensured.
It should be noted that, if the user wants to modify the directory which does not have the modification operation authority, the user may initiate a code merging request, and the user with the authority performs approval, and if the approval passes, the modification operation may be performed, and the specific implementation manner is similar to that of the related technology. For example, still referring to FIG. 2, team A may initiate a code merge request if it wants to modify catalog Y, which is code censored by team B, and team A may modify catalog Y if the approval passes.
In a possible implementation manner, in the case that the directory in the target branch meets the preset directory protection condition in the above step, a specific implementation manner of intercepting the push operation may be:
determining whether the directory in the target branch includes at least one protection directory;
in the event that the directory in the target branch includes at least one protection directory, the push operation is intercepted.
In the embodiment of the present disclosure, when the directory in the target branch meets a preset directory protection condition, the directory under the target branch may be acquired first, where the directory may be one or more, and a protection directory included in the preset directory protection condition may also be acquired when the push operation is intercepted. The directory under the target branch may then be compared to the protection directory to determine whether the directory of the target branch includes one or more protection directories. If the directory in the target branch includes at least one protection directory, it may be considered that the user may have changed the directory that does not have the change authority, at which point the push operation may be intercepted. Taking the example that the catalogs under the target branch comprise catalogs 1, 2, 3, 4, 5, 6, 7, 8 and 9, and the protecting catalogs comprise catalogs 3, 6, 10 and 15, it can be determined that the catalogs under the target branch comprise two protecting catalogs which are respectively catalogs 3 and 6, and the pushing operation can be intercepted. Therefore, the accuracy of interception pushing operation can be improved and the safety of code library codes can be further improved through the sequential comparison of the catalogue in the target branch and the protection catalogue.
In a further possible implementation manner, in the case that the directory in the target branch includes at least one protection directory in the above step, intercepting the push operation includes:
acquiring change directory information of push operation under the condition that the directory in the target branch comprises at least one protection directory;
determining whether the change directory includes at least one protection directory;
in the case that the change directory includes at least one protection directory, the push operation is intercepted.
The change catalog information comprises at least one change catalog for performing change operation, and the change catalog information can be in a list form.
In an embodiment of the present disclosure, considering that a plurality of directories may be included in a target branch, a user may not perform a change operation on all directories under the target branch, and a directory belonging to a protection directory in the directories under the target branch may not be changed by the user. Therefore, when the directory in the target branch includes at least one protection directory, the change target information of the push operation may be obtained first, that is, the directory information of the user performing the change operation on the directory in the target branch may be obtained, that is, the change directory information may be a change directory list, where one or more change directories may be included in the change directory list. The change catalog may then be compared to the protection catalog to determine if the change catalog includes the protection catalog. If the change directory comprises one or more protection directories, the user can be considered to change the directory which does not have the change authority, and the pushing operation is intercepted. Therefore, the pushing operation of the user can be further ensured to be intercepted only when the user changes the directory which does not have the changing authority, so that the accuracy of the code base operation is improved, and the condition of intercepting the pushing operation by mistake is avoided.
In a further possible implementation manner, the determining whether the change directory includes at least one protection directory in the foregoing step may be as follows:
placing the change catalog information in a temporary catalog; wherein the temporary directory is a directory isolated from the change directory information;
it is determined in the temporary directory whether the change directory includes at least one protection directory.
In embodiments of the present disclosure, it may be determined whether the change directory includes at least one protection directory in a single temporary directory. The temporary directory may be a temporary directory isolated from the change directory information, that is, detection of the change directory may be performed in the isolated temporary directory during the push operation. If the change directory hits the protection directory, the push operation may be intercepted. Otherwise, the pushing operation can be normally pushed to the Git server to complete pushing. Thus, the detection of the change operation information of the push operation can be completed in the isolated temporary directory.
In a further possible embodiment, the specific implementation of determining whether the change directory includes at least one protection directory in the temporary directory may be as follows:
invoking the Gitlab in the temporary directory determines whether the change directory includes at least one protection directory.
In embodiments of the present disclosure, in determining whether the change directory includes at least one protection directory in the temporary directory, a Gitlab may be invoked in the temporary directory to determine whether the change directory includes at least one protection directory. Wherein, gitlab is a Git-based code hosting tool platform. In this way, permission detection of the changed directory can be performed through callback of the Gitlab, that is, whether the changed directory hits the protection directory can be determined through callback of the Gitlab in the isolated temporary directory. Therefore, the protection directory rule setting can be realized on the specified directory of the code library in the Gitlab, then the change operation information of the pushing operation is detected on the Git server, the protection directory authority verification of the change file is realized by calling back the Gitlab by using the hook function of the Git server, and further the directory-level authority control of the Git pushing content is realized.
In a further possible implementation manner, in a case that the change directory includes at least one protection directory, after intercepting the push operation, the method provided by the embodiment of the disclosure may further include the following processing:
the temporary directory is deleted.
In an embodiment of the present disclosure, in a case where the change directory includes at least one protection directory, after intercepting the push operation, the foregoing temporary directory may be deleted. In this way, a large number of garbage objects caused by repeated failed pushing (i.e. interception pushing operations) can be avoided, and invalid expansion of the storage warehouse is avoided.
To make the method provided by the embodiments of the present disclosure clearer, a description is given below of a method for controlling a Git-based code library provided by the embodiments of the present disclosure with reference to fig. 3. As shown in fig. 3, the method comprises the following steps:
in step S301, in the case where the pushing operation of the user is detected, the pushing operation is acquired by the hook function of the server side.
In step S302, it is determined whether the directory in the target branch includes at least one protection directory.
If the directory in the target branch comprises at least one protection directory, steps S303, S304 are performed, whereas step S305 is performed.
In step S303, it is determined whether the change directory includes at least one protection directory.
In step S304, a push operation is intercepted.
In step S305, a push operation is pushed.
The specific implementation manner and technical effects of the present embodiment are similar to those of the above method embodiment, and are not described herein again.
Based on the same inventive concept, the embodiments of the present disclosure further provide a Git-based code library control apparatus, as shown in fig. 4, and fig. 4 is a block diagram of a Git-based code library control apparatus according to an exemplary embodiment. Referring to fig. 4, the Git-based code library control apparatus 400 may include:
an operation obtaining module 410, configured to obtain a pushing operation through a hook function of a server side in a case that the pushing operation of a user is detected; wherein the push operation includes a change operation for a target branch, the target branch including at least one directory;
an operation interception module 420 configured to intercept the push operation if the directory in the target branch satisfies a preset directory protection condition; the preset target protection directory condition is used for indicating a directory which cannot be changed by the user.
In one possible implementation, the preset directory protection condition includes a protection directory, and the protection directory is one or more.
In one possible implementation, the operation interception module 420 includes:
a protection directory determining unit configured to determine whether the directory in the target branch includes at least one of the protection directories;
an operation intercepting unit configured to intercept the push operation in case the directory in the target branch comprises at least one of the protection directories.
In one possible embodiment, the operation interception unit includes:
an information acquisition subunit configured to acquire, in a case where the directory in the target branch includes at least one of the protection directories, changed directory information of the push operation; wherein the change catalog information comprises at least one change catalog for carrying out change operation;
a protection directory determining subunit configured to determine whether the change directory includes at least one of the protection directories;
an operation interception subunit configured to intercept the push operation if the change directory includes at least one of the protection directories.
In a possible implementation manner, the protection directory determining subunit is specifically configured to:
placing the change catalog information in a temporary catalog; wherein the temporary directory is a directory isolated from the change directory information;
determining in the temporary directory whether the change directory includes at least one of the protection directories.
In one possible implementation, the apparatus 400 further includes:
and the catalog deleting module is configured to delete the temporary catalog.
The specific manner in which the various modules perform the operations in the apparatus of the above embodiments have been described in detail in connection with the embodiments of the method, and will not be described in detail herein.
According to embodiments of the present disclosure, the present disclosure also provides an electronic device, a computer-readable storage medium, and a computer program product.
Fig. 5 illustrates a schematic block diagram of an example electronic device 500 that may be used to implement embodiments of the present disclosure. Electronic device 500 is intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 5, the electronic device 500 includes a computing unit 501 that can perform various appropriate actions and processes according to a computer program stored in a Read Only Memory (ROM) 502 or a computer program loaded from a storage unit 508 into a Random Access Memory (RAM) 503. In the RAM503, various programs and data required for the operation of the device 500 can also be stored. The computing unit 501, ROM502, and RAM503 are connected to each other by a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
A number of components in electronic device 500 are connected to I/O interface 505, including: an input unit 506 such as a keyboard, a mouse, etc.; an output unit 507 such as various types of displays, speakers, and the like; a storage unit 508 such as a magnetic disk, an optical disk, or the like; and a communication unit 509 such as a network card, modem, wireless communication transceiver, etc. The communication unit 509 allows the electronic device 500 to exchange information/data with other devices via a computer network such as the internet and/or various telecommunication networks.
The computing unit 501 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of computing unit 501 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various computing units running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 501 performs the respective methods and processes described above, such as the Git-based code library control method. For example, in some embodiments, the Git-based code library control method may be implemented as a computer software program tangibly embodied on a machine-readable medium, such as the storage unit 508. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 500 via the ROM502 and/or the communication unit 509. When the computer program is loaded into RAM503 and executed by the computing unit 501, one or more steps of the Git-based code library control method described above may be performed. Alternatively, in other embodiments, the computing unit 501 may be configured to perform the Git-based code library control method by any other suitable means (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for a computer program product for carrying out methods of the present disclosure may be written in any combination of one or more programming languages. These program code may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus such that the program code, when executed by the processor or controller, causes the functions/operations specified in the flowchart and/or block diagram to be implemented. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of this disclosure, a computer-readable storage medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The computer readable storage medium may be a machine readable signal medium or a machine readable storage medium. The computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a computer-readable storage medium would include one or more wire-based electrical connections, 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.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and pointing device (e.g., a mouse or trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), the internet, and blockchain networks.
The computer system may include a client and a server. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical hosts and VPS service ("Virtual Private Server" or simply "VPS") are overcome. The server may also be a server of a distributed system or a server that incorporates a blockchain.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps recited in the present disclosure may be performed in parallel or sequentially or in a different order, provided that the desired results of the technical solutions of the present disclosure are achieved, and are not limited herein.
The above detailed description should not be taken as limiting the scope of the present disclosure. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present disclosure are intended to be included within the scope of the present disclosure.

Claims (10)

1. The Git-based code base control method is characterized by comprising the following steps of:
under the condition that the pushing operation of a user is detected, acquiring the pushing operation through a hook function of a server side; wherein the push operation includes a change operation for a target branch, the target branch including at least one directory;
intercepting the pushing operation under the condition that the directory in the target branch meets a preset directory protection condition; the preset target protection directory condition is used for indicating a directory which cannot be changed by the user.
2. The Git-based code library control method of claim 1, wherein the preset directory protection condition comprises a protection directory, and the protection directory is one or more.
3. The Git-based code library control method according to claim 2, wherein said intercepting said push operation in case said directory in said target branch satisfies a preset directory protection condition comprises:
determining whether the directory in the target branch includes at least one of the protection directories;
in the event that the directory in the target branch includes at least one of the protection directories, the push operation is intercepted.
4. A Git-based code library control method according to claim 2, wherein said intercepting said push operation in the event that said directory in said target branch comprises at least one of said protection directories comprises:
acquiring change directory information of the push operation under the condition that the directory in the target branch comprises at least one protection directory; wherein the change catalog information comprises at least one change catalog for carrying out change operation;
determining whether the change directory includes at least one of the protection directories;
and intercepting the pushing operation in the case that the change directory comprises at least one protection directory.
5. A Git-based code library control method as claimed in claim 4, wherein said determining whether said change directory comprises at least one of said protection directories comprises:
placing the change catalog information in a temporary catalog; wherein the temporary directory is a directory isolated from the change directory information;
determining in the temporary directory whether the change directory includes at least one of the protection directories.
6. A Git-based code library control method as claimed in claim 5, wherein said determining in said temporary directory whether said change directory comprises at least one of said protection directories comprises:
calling a Gitlab in the temporary directory to determine whether the change directory includes at least one of the protection directories.
7. A Git-based code library control method according to claim 5, wherein, in the case where the change directory comprises at least one of the protection directories, after intercepting the push operation, the method further comprises:
and deleting the temporary directory.
8. A Git-based code library control device, comprising:
the operation acquisition module is configured to acquire pushing operation through a hook function of a server side under the condition that the pushing operation of a user is detected; wherein the push operation includes a change operation for a target branch, the target branch including at least one directory;
an operation interception module configured to intercept the push operation if the directory in the target branch satisfies a preset directory protection condition; the preset target protection directory condition is used for indicating a directory which cannot be changed by the user.
9. An electronic device, comprising:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to execute the instructions to implement a Git-based code library control method as claimed in any one of claims 1 to 6.
10. A computer readable storage medium, which when executed by a processor of an electronic device, causes the electronic device to perform the Git-based code library control method of any one of claims 1-6.
CN202310374716.7A 2023-04-10 2023-04-10 Git-based code library control method and device and electronic equipment Pending CN116451272A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310374716.7A CN116451272A (en) 2023-04-10 2023-04-10 Git-based code library control method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310374716.7A CN116451272A (en) 2023-04-10 2023-04-10 Git-based code library control method and device and electronic equipment

Publications (1)

Publication Number Publication Date
CN116451272A true CN116451272A (en) 2023-07-18

Family

ID=87121393

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310374716.7A Pending CN116451272A (en) 2023-04-10 2023-04-10 Git-based code library control method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN116451272A (en)

Similar Documents

Publication Publication Date Title
US10956403B2 (en) Verifying data consistency
CN110225104B (en) Data acquisition method and device and terminal equipment
US9514176B2 (en) Database update notification method
CN112905537B (en) File processing method and device, electronic equipment and storage medium
CN112597126A (en) Data migration method and device
CN110244963B (en) Data updating method and device and terminal equipment
CN110688305B (en) Test environment synchronization method, device, medium and electronic equipment
CN112783447A (en) Method, apparatus, device, medium, and article of manufacture for processing snapshots
CN116451272A (en) Git-based code library control method and device and electronic equipment
CN112506796B (en) Data processing method, device, equipment and storage medium
CN114417070A (en) Method, device and equipment for converging data authority and storage medium
CN114003497A (en) Method, device and equipment for testing service system and storage medium
CN108959405B (en) Strong consistency reading method of data and terminal equipment
CN113326038A (en) Method, apparatus, device, storage medium and program product for providing service
CN108196979B (en) Data backup method and device
CN116521488B (en) Metadata-based self-defined document tracing method, device, equipment and medium
CN113760765B (en) Code testing method and device, electronic equipment and storage medium
CN114546705B (en) Operation response method, operation response device, electronic apparatus, and storage medium
CN114721697A (en) Hot patch processing method and device
CN114490729A (en) Data acquisition method, device and equipment based on multiple databases
CN115952061A (en) Method, device, equipment and storage medium for issuing equipment fingerprint
CN116932033A (en) Component packaging method and device, electronic equipment and storage medium
CN117251417A (en) File copying method and device, electronic equipment and storage medium
CN116303256A (en) Data processing method and device and electronic equipment
CN117235725A (en) Method and device for acquiring software package name, electronic equipment and storage medium

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