Merge branch 'master' into 13-repo-commits

This commit is contained in:
6543 2020-03-30 23:12:07 +00:00
commit c2505d66b5
2 changed files with 19 additions and 6 deletions

View File

@ -25,7 +25,9 @@ import org.mian.gitnex.models.OrganizationRepository;
import org.mian.gitnex.util.AppUtil;
import org.mian.gitnex.util.TinyDB;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;
import retrofit2.Call;
import retrofit2.Callback;
@ -46,6 +48,10 @@ public class CreateRepoActivity extends BaseActivity {
List<OrgOwner> organizationsList = new ArrayList<>();
//https://github.com/go-gitea/gitea/blob/52cfd2743c0e85b36081cf80a850e6a5901f1865/models/repo.go#L964-L967
final List<String> reservedRepoNames = Arrays.asList(".", "..");
final Pattern reservedRepoPatterns = Pattern.compile("\\.(git|wiki)$");
@Override
protected int getLayoutResourceId(){
return R.layout.activity_new_repo;
@ -105,7 +111,6 @@ public class CreateRepoActivity extends BaseActivity {
createRepo.setOnClickListener(createRepoListener);
}
}
private View.OnClickListener createRepoListener = new View.OnClickListener() {
@ -153,15 +158,23 @@ public class CreateRepoActivity extends BaseActivity {
Toasty.info(getApplicationContext(), getString(R.string.repoNameErrorInvalid));
}
else if (reservedRepoNames.contains(newRepoName)) {
Toasty.info(getApplicationContext(), getString(R.string.repoNameErrorReservedName));
}
else if (reservedRepoPatterns.matcher(newRepoName).find()) {
Toasty.info(getApplicationContext(), getString(R.string.repoNameErrorReservedPatterns));
}
else {
//Log.i("repoOwner", String.valueOf(repoOwner));
disableProcessButton();
createNewRepository(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), loginUid, newRepoName, newRepoDesc, repoOwner, newRepoAccess);
}
}
private void createNewRepository(final String instanceUrl, final String token, String loginUid, String repoName, String repoDesc, String repoOwner, boolean isPrivate) {
@ -229,7 +242,6 @@ public class CreateRepoActivity extends BaseActivity {
enableProcessButton();
}
});
}
private void getOrganizations(String instanceUrl, String instanceToken, final String userLogin) {
@ -304,7 +316,6 @@ public class CreateRepoActivity extends BaseActivity {
enableProcessButton();
}
});
}
private void initCloseListener() {

View File

@ -102,6 +102,8 @@
<string name="repoNameErrorEmpty">Repository name is empty</string>
<string name="repoNameErrorInvalid">Repository name is not valid. [a&#8211;z A&#8211;Z 0&#8211;9 &#8211; _]</string>
<string name="repoNameErrorReservedName">Repository name is reserved</string>
<string name="repoNameErrorReservedPatterns">Repository name contains reserved keywords</string>
<string name="repoDescError">Repository description exceeds the max 255 characters limit</string>
<string name="repoCreated">Repository created successfully</string>
<string name="repoCreatedError">Something went wrong, please try again</string>