Skip to content

Commit

Permalink
add unit test for bitbucket web launch, use https rather than ssh
Browse files Browse the repository at this point in the history
I think it's better to default to https rather than ssh clone urls for this
case because SSH access requires the user to have an SSH key installed -
even if it's a public repo.

also normalise formatting of AndroidManifest
  • Loading branch information
rtyley committed May 24, 2012
1 parent bb51a0c commit 4bcdd1e
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 7 deletions.
12 changes: 6 additions & 6 deletions agit/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@
</intent-filter>
</activity>

<activity android:name=".weblaunchers.BitBucketWebLaunchActivity" android:label="@string/app_name">
<activity android:label="@string/app_name" android:name=".weblaunchers.BitBucketWebLaunchActivity">
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE"></category>
<action android:name="android.intent.action.VIEW"></action>
<data android:host="bitbucket.org" android:scheme="https" android:pathPattern="/.*/.*" />
<data android:host="bitbucket.org" android:scheme="http" android:pathPattern="/.*/.*" />
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<action android:name="android.intent.action.VIEW"/>
<data android:host="bitbucket.org" android:pathPattern="/.*/.*" android:scheme="https"/>
<data android:host="bitbucket.org" android:pathPattern="/.*/.*" android:scheme="http"/>
</intent-filter>
</activity>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ public class BitBucketWebLaunchActivity extends WebLaunchActivity {
Intent cloneLauncherForWebBrowseIntent(Uri uri) {
Matcher matcher = projectPathPattern.matcher(uri.getPath());
matcher.find();
return cloneLauncherIntentFor("git@bitbucket.org:"+ matcher.group(1) +".git");
return cloneLauncherIntentFor("https://bitbucket.org/"+ matcher.group(1) +".git");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.madgag.agit.weblaunchers;

import static com.madgag.agit.GitIntents.sourceUriFrom;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import android.net.Uri;

import com.google.inject.Inject;
import com.madgag.agit.InjectedTestRunner;

import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(InjectedTestRunner.class)
public class BitBucketWebLaunchActivityTest {

@Inject
BitBucketWebLaunchActivity activity;

@Test
public void shouldSupplyCloneSourceFromBitBucketProjectPage() {
String projectUrl = "https://bitbucket.org/grubix/git";
assertThat(sourceUriDerivedFrom(projectUrl), is("https://bitbucket.org/grubix/git.git"));
}

@Test
public void shouldSupplyCloneSourceFromBitBucketCheckoutPage() {
String sourceUri = sourceUriDerivedFrom("https://bitbucket.org/grubix/git/src");
assertThat(sourceUri, is("https://bitbucket.org/grubix/git.git"));
}

private String sourceUriDerivedFrom(String url) {
return sourceUriFrom(activity.cloneLauncherForWebBrowseIntent(Uri.parse(url)));
}

}

0 comments on commit 4bcdd1e

Please sign in to comment.