| | |
| | | import java.util.Collections;
|
| | | import java.util.List;
|
| | |
|
| | | import org.apache.wicket.ajax.AjaxRequestTarget;
|
| | | import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
|
| | | import org.apache.wicket.behavior.SimpleAttributeModifier;
|
| | | import org.apache.wicket.markup.html.form.Button;
|
| | | import org.apache.wicket.markup.html.form.CheckBox;
|
| | | import org.apache.wicket.markup.html.form.DropDownChoice;
|
| | | import org.apache.wicket.markup.html.form.Form;
|
| | | import org.apache.wicket.model.CompoundPropertyModel;
|
| | | import org.apache.wicket.model.IModel;
|
| | |
| | | import com.gitblit.wicket.GitBlitWebSession;
|
| | | import com.gitblit.wicket.WicketUtils;
|
| | | import com.gitblit.wicket.panels.AccessPolicyPanel;
|
| | | import com.gitblit.wicket.panels.BooleanChoiceOption;
|
| | | import com.gitblit.wicket.panels.BooleanOption;
|
| | | import com.gitblit.wicket.panels.RepositoryNamePanel;
|
| | | import com.google.common.base.Optional;
|
| | |
|
| | | public class NewRepositoryPage extends RootSubPage {
|
| | |
|
| | |
| | | if (addGitignore) {
|
| | | gitignore = gitignoreModel.getObject();
|
| | | if (StringUtils.isEmpty(gitignore)) {
|
| | | throw new GitBlitException("Please select a .gitignore file");
|
| | | throw new GitBlitException(getString("gb.pleaseSelectGitIgnore"));
|
| | | }
|
| | | }
|
| | |
|
| | |
| | |
|
| | | } catch (GitBlitException e) {
|
| | | error(e.getMessage());
|
| | | namePanel.resetModel(repositoryModel);
|
| | | return;
|
| | | }
|
| | | setRedirect(true);
|
| | |
| | |
|
| | | // add README
|
| | | addReadmeModel = Model.of(false);
|
| | | form.add(new CheckBox("addReadme", addReadmeModel));
|
| | | form.add(new BooleanOption("addReadme",
|
| | | getString("gb.initWithReadme"),
|
| | | getString("gb.initWithReadmeDescription"),
|
| | | addReadmeModel));
|
| | |
|
| | | // add .gitignore
|
| | | File gitignoreDir = app().runtime().getFileOrFolder(Keys.git.gitignoreFolder, "${baseFolder}/gitignore");
|
| | |
| | | }
|
| | | }
|
| | | Collections.sort(gitignores);
|
| | |
|
| | | gitignoreModel = Model.of("");
|
| | | final DropDownChoice<String> gitignoreChoice = new DropDownChoice<String>("gitignore", gitignoreModel, gitignores);
|
| | | gitignoreChoice.setOutputMarkupId(true);
|
| | | form.add(gitignoreChoice.setEnabled(false));
|
| | |
|
| | | addGitignoreModel = Model.of(false);
|
| | | final CheckBox gitignoreCheckbox = new CheckBox("addGitignore", addGitignoreModel);
|
| | | form.add(gitignoreCheckbox);
|
| | | form.add(new BooleanChoiceOption<String>("addGitIgnore",
|
| | | getString("gb.initWithGitignore"),
|
| | | getString("gb.initWithGitignoreDescription"),
|
| | | addGitignoreModel,
|
| | | gitignoreModel,
|
| | | gitignores).setVisible(gitignores.size() > 0));
|
| | |
|
| | | gitignoreCheckbox.add(new AjaxFormComponentUpdatingBehavior("onchange") {
|
| | |
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | @Override
|
| | | protected void onUpdate(AjaxRequestTarget target) {
|
| | | gitignoreChoice.setEnabled(addGitignoreModel.getObject());
|
| | | target.addComponent(gitignoreChoice);
|
| | | }
|
| | | });
|
| | |
|
| | | // TODO add .gitflow
|
| | | // TODO consider gitflow at creation (ticket-55)
|
| | | addGitflowModel = Model.of(false);
|
| | | form.add(new CheckBox("addGitflow", addGitflowModel));
|
| | | form.add(new BooleanOption("addGitFlow",
|
| | | "Include a .gitflow file",
|
| | | "This will generate a config file which guides Git clients in setting up Gitflow branches.",
|
| | | addGitflowModel).setVisible(false));
|
| | |
|
| | | form.add(new Button("create"));
|
| | |
|
| | |
| | | try {
|
| | |
|
| | | UserModel user = GitBlitWebSession.get().getUser();
|
| | | PersonIdent author = new PersonIdent(user.getDisplayName(), user.emailAddress);
|
| | | String email = Optional.fromNullable(user.emailAddress).or(user.username + "@" + "gitblit");
|
| | | PersonIdent author = new PersonIdent(user.getDisplayName(), email);
|
| | |
|
| | | DirCache newIndex = DirCache.newInCore();
|
| | | DirCacheBuilder indexBuilder = newIndex.builder();
|
| | |
| | | }
|
| | | }
|
| | | } finally {
|
| | | revWalk.release();
|
| | | revWalk.close();
|
| | | }
|
| | | } catch (UnsupportedEncodingException e) {
|
| | | logger().error(null, e);
|
| | | } catch (IOException e) {
|
| | | logger().error(null, e);
|
| | | } finally {
|
| | | odi.release();
|
| | | odi.close();
|
| | | db.close();
|
| | | }
|
| | | return success;
|