mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	Fix datarace on git.GlobalCommandArgs on tests (#9162)
* fix datarace on git.GlobalCommandArgs on tests * fix tests * fix tests * fix tests
This commit is contained in:
		
				
					committed by
					
						
						Antoine GIRARD
					
				
			
			
				
	
			
			
			
						parent
						
							9d9e6ac411
						
					
				
				
					commit
					7b7d382b8b
				
			@@ -207,7 +207,12 @@ func (c *Commit) GetCommitByPath(relpath string) (*Commit, error) {
 | 
			
		||||
 | 
			
		||||
// AddChanges marks local changes to be ready for commit.
 | 
			
		||||
func AddChanges(repoPath string, all bool, files ...string) error {
 | 
			
		||||
	cmd := NewCommand("add")
 | 
			
		||||
	return AddChangesWithArgs(repoPath, GlobalCommandArgs, all, files...)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// AddChangesWithArgs marks local changes to be ready for commit.
 | 
			
		||||
func AddChangesWithArgs(repoPath string, gloablArgs []string, all bool, files ...string) error {
 | 
			
		||||
	cmd := NewCommandNoGlobals(append(gloablArgs, "add")...)
 | 
			
		||||
	if all {
 | 
			
		||||
		cmd.AddArguments("--all")
 | 
			
		||||
	}
 | 
			
		||||
@@ -226,7 +231,15 @@ type CommitChangesOptions struct {
 | 
			
		||||
// CommitChanges commits local changes with given committer, author and message.
 | 
			
		||||
// If author is nil, it will be the same as committer.
 | 
			
		||||
func CommitChanges(repoPath string, opts CommitChangesOptions) error {
 | 
			
		||||
	cmd := NewCommand()
 | 
			
		||||
	cargs := make([]string, len(GlobalCommandArgs))
 | 
			
		||||
	copy(cargs, GlobalCommandArgs)
 | 
			
		||||
	return CommitChangesWithArgs(repoPath, cargs, opts)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CommitChangesWithArgs commits local changes with given committer, author and message.
 | 
			
		||||
// If author is nil, it will be the same as committer.
 | 
			
		||||
func CommitChangesWithArgs(repoPath string, args []string, opts CommitChangesOptions) error {
 | 
			
		||||
	cmd := NewCommandNoGlobals(args...)
 | 
			
		||||
	if opts.Committer != nil {
 | 
			
		||||
		cmd.AddArguments("-c", "user.name="+opts.Committer.Name, "-c", "user.email="+opts.Committer.Email)
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user