code.gitea.io/gitea@v1.19.3/modules/git/tree_entry_mode.go (about)

     1  // Copyright 2020 The Gitea Authors. All rights reserved.
     2  // SPDX-License-Identifier: MIT
     3  
     4  package git
     5  
     6  import "strconv"
     7  
     8  // EntryMode the type of the object in the git tree
     9  type EntryMode int
    10  
    11  // There are only a few file modes in Git. They look like unix file modes, but they can only be
    12  // one of these.
    13  const (
    14  	// EntryModeBlob
    15  	EntryModeBlob EntryMode = 0o100644
    16  	// EntryModeExec
    17  	EntryModeExec EntryMode = 0o100755
    18  	// EntryModeSymlink
    19  	EntryModeSymlink EntryMode = 0o120000
    20  	// EntryModeCommit
    21  	EntryModeCommit EntryMode = 0o160000
    22  	// EntryModeTree
    23  	EntryModeTree EntryMode = 0o040000
    24  )
    25  
    26  // String converts an EntryMode to a string
    27  func (e EntryMode) String() string {
    28  	return strconv.FormatInt(int64(e), 8)
    29  }
    30  
    31  // ToEntryMode converts a string to an EntryMode
    32  func ToEntryMode(value string) EntryMode {
    33  	v, _ := strconv.ParseInt(value, 8, 32)
    34  	return EntryMode(v)
    35  }