github.com/gitbundle/modules@v0.0.0-20231025071548-85b91c5c3b01/git/tree_entry_mode.go (about)

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