mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-29 10:57:44 +09:00 
			
		
		
		
	Implement git refs API for listing references (branches, tags and other) (#5354)
* Inital routes to git refs api * Git refs API implementation * Update swagger * Fix copyright * Make swagger happy add basic test * Fix test * Fix test again :)
This commit is contained in:
		
				
					committed by
					
						 techknowlogick
						techknowlogick
					
				
			
			
				
	
			
			
			
						parent
						
							294904321c
						
					
				
				
					commit
					08bf443016
				
			
							
								
								
									
										56
									
								
								vendor/github.com/src-d/gcfg/token/serialize.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								vendor/github.com/src-d/gcfg/token/serialize.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,56 @@ | ||||
| // Copyright 2011 The Go Authors. All rights reserved. | ||||
| // Use of this source code is governed by a BSD-style | ||||
| // license that can be found in the LICENSE file. | ||||
|  | ||||
| package token | ||||
|  | ||||
| type serializedFile struct { | ||||
| 	// fields correspond 1:1 to fields with same (lower-case) name in File | ||||
| 	Name  string | ||||
| 	Base  int | ||||
| 	Size  int | ||||
| 	Lines []int | ||||
| 	Infos []lineInfo | ||||
| } | ||||
|  | ||||
| type serializedFileSet struct { | ||||
| 	Base  int | ||||
| 	Files []serializedFile | ||||
| } | ||||
|  | ||||
| // Read calls decode to deserialize a file set into s; s must not be nil. | ||||
| func (s *FileSet) Read(decode func(interface{}) error) error { | ||||
| 	var ss serializedFileSet | ||||
| 	if err := decode(&ss); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	s.mutex.Lock() | ||||
| 	s.base = ss.Base | ||||
| 	files := make([]*File, len(ss.Files)) | ||||
| 	for i := 0; i < len(ss.Files); i++ { | ||||
| 		f := &ss.Files[i] | ||||
| 		files[i] = &File{s, f.Name, f.Base, f.Size, f.Lines, f.Infos} | ||||
| 	} | ||||
| 	s.files = files | ||||
| 	s.last = nil | ||||
| 	s.mutex.Unlock() | ||||
|  | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Write calls encode to serialize the file set s. | ||||
| func (s *FileSet) Write(encode func(interface{}) error) error { | ||||
| 	var ss serializedFileSet | ||||
|  | ||||
| 	s.mutex.Lock() | ||||
| 	ss.Base = s.base | ||||
| 	files := make([]serializedFile, len(s.files)) | ||||
| 	for i, f := range s.files { | ||||
| 		files[i] = serializedFile{f.name, f.base, f.size, f.lines, f.infos} | ||||
| 	} | ||||
| 	ss.Files = files | ||||
| 	s.mutex.Unlock() | ||||
|  | ||||
| 	return encode(ss) | ||||
| } | ||||
		Reference in New Issue
	
	Block a user