Skip to content
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

Buildasaur doesn't extract repo name from GitHub url that does not end in ".git" #244

Closed
lindsaylandry opened this issue Mar 1, 2016 · 6 comments
Assignees
Labels

Comments

@lindsaylandry
Copy link
Contributor

Sometimes github strings do not have ".git" attached to the end.
If this happens, Buildasaur will give an error message on the SSH Keys setup page. The message says: "Invalid repo name."

Example github string (without ".git"):
git@github.com:organization/repo_name

I have a fix that will address both kinds of strings to extract the repo name (basically creates a Range object that starts and ends at the end of the string if it cannot find ".git")
Project.swift.zip

Buildasaur/BuildaKit/Project.swift

Replace the following lines:

- if let githubRange = stringUrl.rangeOfString(serviceUrl, options: NSStringCompareOptions(), range: nil, locale: nil),
- let dotGitRange = stringUrl.rangeOfString(".git", options: NSStringCompareOptions.BackwardsSearch, range: nil, locale: nil) {

+ let dotGitRange = stringUrl.rangeOfString(".git", options: NSStringCompareOptions.BackwardsSearch, range: nil, locale: nil) ?? Range(start: stringUrl.endIndex, end: stringUrl.endIndex)
+ if let githubRange = stringUrl.rangeOfString(serviceUrl, options: NSStringCompareOptions(), range: nil, locale: nil){

@czechboy0
Copy link
Member

Hi @lindsaylandry,

thanks for reporting this. I'm however wondering whether a git remote URL not ending with .git is a valid git URL? Do you have an example of a GitHub project that has a git URL not ending with .git? Because this is new to me so I need to understand the issue first :)

@czechboy0
Copy link
Member

Ok, TIL that you don't need the .git suffix.

Thanks so much for reporting this! Could you fork this repo and send a Pull Request with the fix above, so that I can just merge it? If that's a problem, I can apply the fix manually.

@czechboy0 czechboy0 added the bug label Mar 1, 2016
@czechboy0 czechboy0 self-assigned this Mar 1, 2016
@lindsaylandry
Copy link
Contributor Author

Any git repo can be cloned in this way.
For example, your own Buildasaur repo can be cloned like this:

git clone git@github.com:czechboy0/Buildasaur

if you leave the .git extension out, it still works.
I have created a forked branch already, but when I tried to push onto master, I didn't have permission. I can submit a PR if you give me temporary permissions :)

@czechboy0
Copy link
Member

You can just create a fork of the repository if you click on the fork button top right, clone and apply the fix there, and then create a cross-fork Pull Request :) If you haven't worked with forks before, here's some info from github.

@lindsaylandry
Copy link
Contributor Author

oh thanks very much, looks like I learned something today as well.

czechboy0 added a commit that referenced this issue Mar 1, 2016
@czechboy0
Copy link
Member

Fixed by #246.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants