}\r
return success;\r
}\r
+ \r
+ /**\r
+ * Returns true if the commit identified by commitId is at the tip of it's branch.\r
+ *\r
+ * @param repository\r
+ * @param commitId\r
+ * @return true if the given commit is the tip\r
+ */\r
+ public static boolean isTip(Repository repository, String commitId) {\r
+ try {\r
+ RefModel tip = getBranch(repository, commitId);\r
+ return (tip != null); \r
+ } catch (Exception e) {\r
+ LOGGER.error("Failed to determine isTip", e);\r
+ }\r
+ return false;\r
+ }\r
\r
}\r
import com.gitblit.wicket.pages.ComparePage;
import com.gitblit.wicket.pages.DocPage;
import com.gitblit.wicket.pages.DocsPage;
+import com.gitblit.wicket.pages.EditFilePage;
import com.gitblit.wicket.pages.EditMilestonePage;
import com.gitblit.wicket.pages.EditRepositoryPage;
import com.gitblit.wicket.pages.EditTicketPage;
// setup the markup document urls
mount("/docs", DocsPage.class, "r", "h");
mount("/doc", DocPage.class, "r", "h", "f");
+ mount("/editfile", EditFilePage.class, "r", "h", "f");
// federation urls
mount("/proposal", ReviewProposalPage.class, "t");
gb.filestoreStats = Filestore contains {0} files with a total size of {1}. ({2} remaining)
gb.statusChangedOn = status changed on
gb.statusChangedBy = status changed by
-gb.filestoreHelp = How to use the Filestore?
\ No newline at end of file
+gb.filestoreHelp = How to use the Filestore?
+gb.editFile = edit file
+gb.continueEditing = Continue Editing
+gb.commitChanges = Commit Changes
+gb.fileNotMergeable = Unable to commit {0}. This file can not be automatically merged.
+gb.fileCommitted = Successfully committed {0}.
\ No newline at end of file
import java.io.IOException;
+import java.text.MessageFormat;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.gitblit.wicket.MarkupProcessor.MarkupDocument;
import com.gitblit.wicket.WicketUtils;
-@CacheControl(LastModified.BOOT)
+@CacheControl(LastModified.REPOSITORY)
public class EditFilePage extends RepositoryPage {
public EditFilePage(final PageParameters params) {
Fragment fragment;
String displayedCommitId = commit.getId().getName();
MarkupDocument markupDoc = processor.parse(repositoryName, displayedCommitId, documentPath, markupText);
- logger.info("Loading Edit File page: " + displayedCommitId);
+ logger.trace("Loading Edit File page: " + displayedCommitId);
- if (currentUser.canEdit(getRepositoryModel())) {
+ if (currentUser.canEdit(getRepositoryModel()) && JGitUtils.isTip(getRepository(), objectId.toString())) {
final Model<String> documentContent = new Model<String>(markupDoc.markup);
final Model<String> commitMessage = new Model<String>("Document update");
@Override
protected void onSubmit() {
-
final Repository repository = getRepository();
final String document = documentContent.getObject();
final String message = commitMessage.getObject();
try {
ObjectId docAtLoad = getRepository().resolve(commitIdAtLoad.getObject());
- logger.info("Commiting Edit File page: " + commitIdAtLoad.getObject());
+ logger.trace("Commiting Edit File page: " + commitIdAtLoad.getObject());
DirCache index = DirCache.newInCore();
DirCacheBuilder builder = index.builder();
}
if (success == false) {
- EditFilePage.this.error("Unable to commit document " + path, false);
+ getSession().error(MessageFormat.format(getString("gb.fileNotMergeable"),path));
return;
}
+ getSession().info(MessageFormat.format(getString("gb.fileCommitted"),path));
setResponsePage(EditFilePage.class, params);
- return;
}
};
fragment.add(new ExternalLink("rawLink", rawUrl));
add(fragment);
-
+
}
@Override
protected String getPageName() {
- return getString("gb.docs");
+ return getString("gb.editFile");
}
@Override
@Override
protected Class<? extends BasePage> getRepoNavPageClass() {
- return DocsPage.class;
+ return EditFilePage.class;
}