@@ -22,6 +22,8 @@ r18: { | |||
- Fixed Ubuntu service script for LSB compliance | |||
- Inserted "sleep 5" in Ubuntu & Centos bash script for service restart | |||
changes: | |||
- Use trash icon in Gitblit Reflog for branch and tag deletion | |||
- Update Gitblit Reflog on branch deletion from web UI | |||
- updated Chinese translation | |||
- updated Dutch translation | |||
- updated Spanish translation |
@@ -20,6 +20,7 @@ import java.text.DateFormat; | |||
import java.text.MessageFormat; | |||
import java.text.SimpleDateFormat; | |||
import java.util.ArrayList; | |||
import java.util.Arrays; | |||
import java.util.Collection; | |||
import java.util.Collections; | |||
import java.util.Date; | |||
@@ -41,6 +42,7 @@ import org.eclipse.jgit.lib.FileMode; | |||
import org.eclipse.jgit.lib.ObjectId; | |||
import org.eclipse.jgit.lib.ObjectInserter; | |||
import org.eclipse.jgit.lib.PersonIdent; | |||
import org.eclipse.jgit.lib.Ref; | |||
import org.eclipse.jgit.lib.RefRename; | |||
import org.eclipse.jgit.lib.RefUpdate; | |||
import org.eclipse.jgit.lib.RefUpdate.Result; | |||
@@ -96,6 +98,21 @@ public class RefLogUtils { | |||
} | |||
LOGGER.error(MessageFormat.format(pattern, parameters.toArray()), t); | |||
} | |||
/** | |||
* Returns true if the repository has a reflog branch. | |||
* | |||
* @param repository | |||
* @return true if the repository has a reflog branch | |||
*/ | |||
public static boolean hasRefLogBranch(Repository repository) { | |||
try { | |||
return repository.getRef(GB_REFLOG) != null; | |||
} catch(Exception e) { | |||
LOGGER.error("failed to determine hasRefLogBranch", e); | |||
} | |||
return false; | |||
} | |||
/** | |||
* Returns a RefModel for the reflog branch in the repository. If the | |||
@@ -155,6 +172,37 @@ public class RefLogUtils { | |||
return user; | |||
} | |||
/** | |||
* Logs a ref deletion. | |||
* | |||
* @param user | |||
* @param repository | |||
* @param ref | |||
* @return true, if the update was successful | |||
*/ | |||
public static boolean deleteRef(UserModel user, Repository repository, String ref) { | |||
try { | |||
Ref refObj = repository.getRef(ref); | |||
if (refObj == null && !ref.startsWith(Constants.R_HEADS) && ref.startsWith(Constants.R_TAGS)) { | |||
// find fully qualified ref | |||
refObj = repository.getRef(Constants.R_HEADS + ref); | |||
if (refObj == null) { | |||
refObj = repository.getRef(Constants.R_TAGS + ref); | |||
} | |||
} | |||
if (refObj == null) { | |||
return false; | |||
} | |||
ReceiveCommand cmd = new ReceiveCommand(refObj.getObjectId(), ObjectId.zeroId(), refObj.getName()); | |||
return updateRefLog(user, repository, Arrays.asList(cmd)); | |||
} catch (Throwable t) { | |||
error(t, repository, "Failed to commit reflog entry to {0}"); | |||
} | |||
return false; | |||
} | |||
/** | |||
* Updates the reflog with the received commands. | |||
* |
@@ -37,7 +37,9 @@ import com.gitblit.SyndicationServlet; | |||
import com.gitblit.models.RefModel; | |||
import com.gitblit.models.RepositoryModel; | |||
import com.gitblit.models.UserModel; | |||
import com.gitblit.utils.CommitCache; | |||
import com.gitblit.utils.JGitUtils; | |||
import com.gitblit.utils.RefLogUtils; | |||
import com.gitblit.utils.StringUtils; | |||
import com.gitblit.wicket.GitBlitWebSession; | |||
import com.gitblit.wicket.WicketUtils; | |||
@@ -191,15 +193,28 @@ public class BranchesPanel extends BasePanel { | |||
} | |||
return; | |||
} | |||
boolean success = JGitUtils.deleteBranchRef(r, entry.getName()); | |||
final String branch = entry.getName(); | |||
boolean success = JGitUtils.deleteBranchRef(r, branch); | |||
if (success) { | |||
// clear commit cache | |||
CommitCache.instance().clear(repositoryModel.name, branch); | |||
// optionally update reflog | |||
if (RefLogUtils.hasRefLogBranch(r)) { | |||
UserModel user = GitBlitWebSession.get().getUser(); | |||
success = RefLogUtils.deleteRef(user, r, branch); | |||
} | |||
} | |||
r.close(); | |||
if (success) { | |||
info(MessageFormat.format("Branch \"{0}\" deleted", entry.displayName)); | |||
info(MessageFormat.format("Branch \"{0}\" deleted", branch)); | |||
// redirect to the owning page | |||
setResponsePage(getPage().getClass(), WicketUtils.newRepositoryParameter(repositoryModel.name)); | |||
} | |||
else { | |||
error(MessageFormat.format("Failed to delete branch \"{0}\"", entry.displayName)); | |||
error(MessageFormat.format("Failed to delete branch \"{0}\"", branch)); | |||
} | |||
} | |||
}; |
@@ -30,6 +30,7 @@ import org.apache.wicket.markup.repeater.data.DataView; | |||
import org.apache.wicket.markup.repeater.data.ListDataProvider; | |||
import org.apache.wicket.model.StringResourceModel; | |||
import org.eclipse.jgit.lib.Repository; | |||
import org.eclipse.jgit.transport.ReceiveCommand.Type; | |||
import com.gitblit.Constants; | |||
import com.gitblit.GitBlit; | |||
@@ -154,7 +155,9 @@ public class ReflogPanel extends BasePanel { | |||
changeItem.add(new Label("whenChanged", fuzzydate + ", " + df.format(changeDate))); | |||
Label changeIcon = new Label("changeIcon"); | |||
if (isTag) { | |||
if (Type.DELETE.equals(change.getChangeType(fullRefName))) { | |||
WicketUtils.setCssClass(changeIcon, "iconic-trash-stroke"); | |||
} else if (isTag) { | |||
WicketUtils.setCssClass(changeIcon, "iconic-tag"); | |||
} else { | |||
WicketUtils.setCssClass(changeIcon, "iconic-upload"); |