hunk.code_window: 	CommandPrettyPrintln("")
   	if err, lineNumber := a.BulkImport(fileReader, !apply, workers); err != nil {
   		CommandPrettyPrintln(err.Error())
   		if lineNumber != 0 {
  
hunk.labels: keep keep keep replace keep
hunk.after_edit: 		CommandPrintErrorln(err.Error())
  
hunk.file_path: cmd/mattermost/commands/import.go
hunk.type: replace
file: // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
  // See License.txt for license information.
  
  package oauthgitlab
  
  import (
  	"encoding/json"
  	"io"
  	"strconv"
  	"strings"
  
  	"github.com/mattermost/mattermost-server/einterfaces"
  	"github.com/mattermost/mattermost-server/model"
  )
  
  type GitLabProvider struct {
  }
  
  type GitLabUser struct {
  	Id       int64  `json:"id"`
  	Username string `json:"username"`
  	Login    string `json:"login"`
  	Email    string `json:"email"`
  	Name     string `json:"name"`
  }
  
  func init() {
  	provider := &GitLabProvider{}
  	einterfaces.RegisterOauthProvider(model.USER_AUTH_SERVICE_GITLAB, provider)
  }
  
  func userFromGitLabUser(glu *GitLabUser) *model.User {
  	user := &model.User{}
  	username := glu.Username
  	if username == "" {
  		username = glu.Login
  	}
  	user.Username = model.CleanUsername(username)
  	splitName := strings.Split(glu.Name, " ")
  	if len(splitName) == 2 {
  		user.FirstName = splitName[0]
  		user.LastName = splitName[1]
  	} else if len(splitName) >= 2 {
  		user.FirstName = splitName[0]
  		user.LastName = strings.Join(splitName[1:], " ")
  	} else {
  		user.FirstName = glu.Name
  	}
  	user.Email = glu.Email
  	userId := glu.getAuthData()
  	user.AuthData = &userId
  	user.AuthService = model.USER_AUTH_SERVICE_GITLAB
  
  	return user
  }
  
  func gitLabUserFromJson(data io.Reader) *GitLabUser {
  	decoder := json.NewDecoder(data)
  	var glu GitLabUser
  	err := decoder.Decode(&glu)
  	if err == nil {
  		return &glu
  	} else {
  		return nil
  	}
  }
  
  func (glu *GitLabUser) ToJson() string {
  	b, err := json.Marshal(glu)
  	if err != nil {
  		return ""
  	} else {
  		return string(b)
  	}
  }
  
  func (glu *GitLabUser) IsValid() bool {
  	if glu.Id == 0 {
  		return false
  	}
  
  	if len(glu.Email) == 0 {
  		return false
  	}
  
  	return true
  }
  
  func (glu *GitLabUser) getAuthData() string {
  	return strconv.FormatInt(glu.Id, 10)
  }
  
  func (m *GitLabProvider) GetUserFromJson(data io.Reader) *model.User {
  	glu := gitLabUserFromJson(data)
  	if glu.IsValid() {
  		return userFromGitLabUser(glu)
  	}
  
  	return &model.User{}
  }
  