// GetProject gets information about a repository.
193733
func GetProject(ctx context.Context, client *http.Client, importPath string) (*Project, error) {
	for _, s := range services {
		if s.getProject == nil {
			continue
		}
		match, err := s.match(importPath)
		if err != nil {
			return nil, err
		}
		if match != nil {
			return s.getProject(ctx, client, match)
		}
	}
	return nil, NotFoundError{Message: "path does not match registered service"}
}
788957
func (p *ProjectOptions) GetBody() string {
	if p == nil || p.Body == nil {
		return ""
	}
	return *p.Body
}
592955
func (c *Client) SuspendProject(p *SuspendProjectParameter) (*Project, error) {
	obj, err := c.Request("suspendProject", convertParamToMap(p))
	if err != nil {
		return nil, err
	}
	return obj.(*Project), err
}
1243169
func (p *Project) GetState() string {
	if p == nil || p.State == nil {
		return ""
	}
	return *p.State
}
797235
func getProjectID(svc *compute.Service, projectNumberOrID string) (string, error) {
	proj, err := svc.Projects.Get(projectNumberOrID).Do()
	if err != nil {
		return "", err
	}

	return proj.Name, nil
}
701958
func (client DefaultClient) GetProject(projectKey string) (Project, error) {
	req, err := http.NewRequest("GET", fmt.Sprintf("%s/rest/api/2/project/%s", client.baseURL, projectKey), nil)
	if err != nil {
		return Project{}, err
	}
	req.Header.Set("Accept", "application/json")
	req.SetBasicAuth(client.username, client.password)

	responseCode, data, err := client.consumeResponse(req)
	if err != nil {
		return Project{}, err
	}
	if responseCode != http.StatusOK {
		logger.Printf("JIRA response: %s\n", string(data))
		return Project{}, fmt.Errorf("error getting project.  Status code: %d.\n", responseCode)
	}

	var r Project
	if err := json.Unmarshal(data, &r); err != nil {
		return Project{}, err
	}

	return r, nil
}
907209
func (c *ApiController) GetProjectsAll() {
	log.Info("Get all projects")

	projects := models.GetAllProjects()

	c.Data["json"] = projects
	c.ServeJson()
}
1086788
func (p *Project) GetBody() string {
	if p == nil || p.Body == nil {
		return ""
	}
	return *p.Body
}
741773
func (s *ProjectsService) CreateProject(projectName string, input *ProjectInput) (*ProjectInfo, *Response, error) {
	u := fmt.Sprintf("projects/%s/", url.QueryEscape(projectName))

	v := new(ProjectInfo)
	resp, err := s.client.Call("PUT", u, input, v)
	return v, resp, err
}
1124554
func FindProjectroot(path string) (string, error) {
	if path == "" {
		return "", errors.New("project root is blank")
	}
	start := path
	for path != filepath.Dir(path) {
		root := filepath.Join(path, "src")
		if _, err := os.Stat(root); err != nil {
			if os.IsNotExist(err) {
				path = filepath.Dir(path)
				continue
			}
			return "", err
		}
		return path, nil
	}
	return "", fmt.Errorf(`could not find project root in "%s" or its parents`, start)
}
628707
func (client Client) GetRepository(projectKey, repositorySlug string) (Repository, error) {
	retry := retry.New(3, retry.DefaultBackoffFunc)

	var r Repository
	work := func() error {
		req, err := http.NewRequest("GET", fmt.Sprintf("%s/rest/api/1.0/projects/%s/repos/%s", client.baseURL.String(), projectKey, repositorySlug), nil)
		if err != nil {
			return err
		}
		req.Header.Set("Accept", "application/json")
		// use credentials if we have them.  If not, the repository must be public.
		if client.userName != "" && client.password != "" {
			req.SetBasicAuth(client.userName, client.password)
		}

		responseCode, data, err := client.consumeResponse(req)
		if err != nil {
			return err
		}

		if responseCode != http.StatusOK {
			reason := "unhandled reason"
			switch {
			case responseCode == http.StatusNotFound:
				reason = "Not found"
			case responseCode == http.StatusUnauthorized:
				reason = "Unauthorized"
			}
			return errorResponse{StatusCode: responseCode, Reason: reason}
		}

		err = json.Unmarshal(data, &r)
		if err != nil {
			return err
		}
		return nil
	}

	return r, retry.Try(work)
}
169003
func (p *ProjectColumn) GetProjectURL() string {
	if p == nil || p.ProjectURL == nil {
		return ""
	}
	return *p.ProjectURL
}
248478
func (s *RepositoriesService) ListProjects(ctx context.Context, owner, repo string, opt *ProjectListOptions) ([]*Project, *Response, error) {
	u := fmt.Sprintf("repos/%v/%v/projects", owner, repo)
	u, err := addOptions(u, opt)
	if err != nil {
		return nil, nil, err
	}

	req, err := s.client.NewRequest("GET", u, nil)
	if err != nil {
		return nil, nil, err
	}

	// TODO: remove custom Accept headers when APIs fully launch.
	req.Header.Set("Accept", mediaTypeProjectsPreview)

	var projects []*Project
	resp, err := s.client.Do(ctx, req, &projects)
	if err != nil {
		return nil, resp, err
	}

	return projects, resp, nil
}
313363
func GetProjectRoot() (string, error) {
	pwd, err := os.Getwd()
	if err != nil {
		return "", fmt.Errorf("Failed to find project root directory. %s\n", err.Error())
	}
	return findManifestInPath(pwd)
}
992077
func (c *ApiController) GetAccountProjects() {

	//projects := GithubOauthRepositories{{FullName:"ArchCI/archci", HTMLURL:"https://github.com/ArchCI/archci", Language: "Go", Description: "The best CI system"}, {FullName:"ArchCI/simple-worker", Homepage:"https://github.com/ArchCI/simple-worker", Language:"Go", Description: "The client of ArchCI"}}

	/*
		r := c.Ctx.Request
		w := c.Ctx.ResponseWriter

		token := tkn

		sess, _ := globalSessions.SessionStart(w, r)
		defer sess.SessionRelease(w)

		if sess.Get("token") == nil {
			token = sess.Get("token").(*oauth2.Token)

			fmt.Println("hit token")

		}
	*/

	client := github.NewClient(oauthCfg.Client(oauth2.NoContext, tkn))

	projects, _, err := client.Repositories.List("", nil)
	if err != nil {
		fmt.Println("error getting repos")
		//return
	}

	/*
		[
		{
		"id": 36988569,
		"owner": {
		"login": "ArchCI",
		"id": 12673804,
		"avatar_url": "https://avatars.githubusercontent.com/u/12673804?v=3",
		"html_url": "https://github.com/ArchCI",
		"gravatar_id": "",
		"type": "Organization",
		"site_admin": false,
		"url": "https://api.github.com/users/ArchCI",
		"events_url": "https://api.github.com/users/ArchCI/events{/privacy}",
		"following_url": "https://api.github.com/users/ArchCI/following{/other_user}",
		"followers_url": "https://api.github.com/users/ArchCI/followers",
		"gists_url": "https://api.github.com/users/ArchCI/gists{/gist_id}",
		"organizations_url": "https://api.github.com/users/ArchCI/orgs",
		"received_events_url": "https://api.github.com/users/ArchCI/received_events",
		"repos_url": "https://api.github.com/users/ArchCI/repos",
		"starred_url": "https://api.github.com/users/ArchCI/starred{/owner}{/repo}",
		"subscriptions_url": "https://api.github.com/users/ArchCI/subscriptions"
		},
		"name": "aci",
		"full_name": "ArchCI/aci",
		"description": "Command-line client for ArchCI",
		"homepage": "http://archci.com",
		"default_branch": "master",
		"created_at": "2015-06-06T17:21:16Z",
		"pushed_at": "2015-06-14T01:00:11Z",
		"updated_at": "2015-06-28T13:58:55Z",
		"html_url": "https://github.com/ArchCI/aci",
		"clone_url": "https://github.com/ArchCI/aci.git",
		"git_url": "git://github.com/ArchCI/aci.git",
		"ssh_url": "git@github.com:ArchCI/aci.git",
		"svn_url": "https://github.com/ArchCI/aci",
		"language": "Go",
		"fork": false,
		"forks_count": 0,
		"open_issues_count": 0,
		"stargazers_count": 1,
		"watchers_count": 1,
		"size": 168,
		"permissions": {
		"admin": true,
		"pull": true,
		"push": true
		},
		"private": false,
		"has_issues": true,
		"has_wiki": true,
		"has_downloads": true,
		"team_id": null,
		"url": "https://api.github.com/repos/ArchCI/aci",
		"archive_url": "https://api.github.com/repos/ArchCI/aci/{archive_format}{/ref}",
		"assignees_url": "https://api.github.com/repos/ArchCI/aci/assignees{/user}",
		"blobs_url": "https://api.github.com/repos/ArchCI/aci/git/blobs{/sha}",
		"branches_url": "https://api.github.com/repos/ArchCI/aci/branches{/branch}",
		"collaborators_url": "https://api.github.com/repos/ArchCI/aci/collaborators{/collaborator}",
		"comments_url": "https://api.github.com/repos/ArchCI/aci/comments{/number}",
		"commits_url": "https://api.github.com/repos/ArchCI/aci/commits{/sha}",
		"compare_url": "https://api.github.com/repos/ArchCI/aci/compare/{base}...{head}",
		"contents_url": "https://api.github.com/repos/ArchCI/aci/contents/{+path}",
		"contributors_url": "https://api.github.com/repos/ArchCI/aci/contributors",
		"downloads_url": "https://api.github.com/repos/ArchCI/aci/downloads",
		"events_url": "https://api.github.com/repos/ArchCI/aci/events",
		"forks_url": "https://api.github.com/repos/ArchCI/aci/forks",
		"git_commits_url": "https://api.github.com/repos/ArchCI/aci/git/commits{/sha}",
		"git_refs_url": "https://api.github.com/repos/ArchCI/aci/git/refs{/sha}",
		"git_tags_url": "https://api.github.com/repos/ArchCI/aci/git/tags{/sha}",
		"hooks_url": "https://api.github.com/repos/ArchCI/aci/hooks",
		"issue_comment_url": "https://api.github.com/repos/ArchCI/aci/issues/comments{/number}",
		"issue_events_url": "https://api.github.com/repos/ArchCI/aci/issues/events{/number}",
		"issues_url": "https://api.github.com/repos/ArchCI/aci/issues{/number}",
		"keys_url": "https://api.github.com/repos/ArchCI/aci/keys{/key_id}",
		"labels_url": "https://api.github.com/repos/ArchCI/aci/labels{/name}",
		"languages_url": "https://api.github.com/repos/ArchCI/aci/languages",
		"merges_url": "https://api.github.com/repos/ArchCI/aci/merges",
		"milestones_url": "https://api.github.com/repos/ArchCI/aci/milestones{/number}",
		"notifications_url": "https://api.github.com/repos/ArchCI/aci/notifications{?since,all,participating}",
		"pulls_url": "https://api.github.com/repos/ArchCI/aci/pulls{/number}",
		"releases_url": "https://api.github.com/repos/ArchCI/aci/releases{/id}",
		"stargazers_url": "https://api.github.com/repos/ArchCI/aci/stargazers",
		"statuses_url": "https://api.github.com/repos/ArchCI/aci/statuses/{sha}",
		"subscribers_url": "https://api.github.com/repos/ArchCI/aci/subscribers",
		"subscription_url": "https://api.github.com/repos/ArchCI/aci/subscription",
		"tags_url": "https://api.github.com/repos/ArchCI/aci/tags",
		"trees_url": "https://api.github.com/repos/ArchCI/aci/git/trees{/sha}",
		"teams_url": "https://api.github.com/repos/ArchCI/aci/teams"
		}
		]
	*/

	c.Data["json"] = projects
	c.ServeJson()

}
77078
func (s *persistentStorage) LookupByProject(c context.Context, project string) (*ProjectIdentity, error) {
	return s.lookup(c, &ProjectIdentity{Project: project})
}
181020
func (p *ProjectOptions) GetPublic() bool {
	if p == nil || p.Public == nil {
		return false
	}
	return *p.Public
}