forked from rtyley/agit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
agit/src/main/java/com/madgag/agit/weblaunchers/BitBucketWebLaunchActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
agit/src/test/java/com/madgag/agit/weblaunchers/BitBucketWebLaunchActivityTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))); | ||
} | ||
|
||
} |