Skip to content

fixes getProjects(namespace, name) with a search #208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fixes getProjects(namespace, name) with a search
  • Loading branch information
Cédric Tabin committed May 18, 2017
commit 00fdf580b2eeedc7f0d6c08494a1640044cf711d
11 changes: 9 additions & 2 deletions src/main/java/org/gitlab/api/GitlabAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,15 @@ public GitlabProject getProject(Serializable projectId) throws IOException {
* use namespace & project name to get project
*/
public GitlabProject getProject(String namespace, String projectName) throws IOException{
String tailUrl = GitlabProject.URL + "/" + namespace + "%2F" + projectName;
return retrieve().to(tailUrl, GitlabProject.class);
String fullName = namespace+" / "+projectName;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be?

String fullName = namespace + "/" + projectName;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested on our internal GitLab and we really have a space between each side of the slash. It's working with the changes.

However, may this be a GitLab configuration ?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmmm. It might just be stripping whitespace?

String tailUrl = GitlabProject.URL + "?search=" + projectName;
GitlabProject[] projects = retrieve().to(tailUrl, GitlabProject[].class);
for(GitlabProject gp : projects) {
if(gp.getNameWithNamespace().equals(fullName)) {
return gp;
}
}
return null;
}

/**
Expand Down