mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	* 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 :)
		
			
				
	
	
		
			23 lines
		
	
	
		
			487 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			23 lines
		
	
	
		
			487 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package git
 | 
						|
 | 
						|
import "strings"
 | 
						|
 | 
						|
const defaultDotGitPath = ".git"
 | 
						|
 | 
						|
// countLines returns the number of lines in a string à la git, this is
 | 
						|
// The newline character is assumed to be '\n'.  The empty string
 | 
						|
// contains 0 lines.  If the last line of the string doesn't end with a
 | 
						|
// newline, it will still be considered a line.
 | 
						|
func countLines(s string) int {
 | 
						|
	if s == "" {
 | 
						|
		return 0
 | 
						|
	}
 | 
						|
 | 
						|
	nEOL := strings.Count(s, "\n")
 | 
						|
	if strings.HasSuffix(s, "\n") {
 | 
						|
		return nEOL
 | 
						|
	}
 | 
						|
 | 
						|
	return nEOL + 1
 | 
						|
}
 |