Skip to content

Commit

Permalink
Merge branch 'web-launch-bitbucket'
Browse files Browse the repository at this point in the history
  • Loading branch information
rtyley committed May 24, 2012
2 parents 213de46 + 4bcdd1e commit e82e127
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
10 changes: 10 additions & 0 deletions agit/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,16 @@
</intent-filter>
</activity>

<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"/>
<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>

<service android:name="GitOperationsService">
<intent-filter>
<action android:name="org.openintents.git.repo.SYNC"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.madgag.agit.weblaunchers;

import android.content.Intent;
import android.net.Uri;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static com.madgag.agit.CloneLauncherActivity.cloneLauncherIntentFor;
import static java.util.regex.Pattern.compile;


public class BitBucketWebLaunchActivity extends WebLaunchActivity {

private static final String TAG = "WL-bitbucket";

private static final Pattern projectPathPattern = compile("^/([^/]+/[^/]+)");

Intent cloneLauncherForWebBrowseIntent(Uri uri) {
Matcher matcher = projectPathPattern.matcher(uri.getPath());
matcher.find();
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 e82e127

Please sign in to comment.