- Fixed Ubuntu service script for LSB compliance | - Fixed Ubuntu service script for LSB compliance | ||||
- Inserted "sleep 5" in Ubuntu & Centos bash script for service restart | - Inserted "sleep 5" in Ubuntu & Centos bash script for service restart | ||||
changes: | 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 Chinese translation | ||||
- updated Dutch translation | - updated Dutch translation | ||||
- updated Spanish translation | - updated Spanish translation |
import java.text.MessageFormat; | import java.text.MessageFormat; | ||||
import java.text.SimpleDateFormat; | import java.text.SimpleDateFormat; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Arrays; | |||||
import java.util.Collection; | import java.util.Collection; | ||||
import java.util.Collections; | import java.util.Collections; | ||||
import java.util.Date; | import java.util.Date; | ||||
import org.eclipse.jgit.lib.ObjectId; | import org.eclipse.jgit.lib.ObjectId; | ||||
import org.eclipse.jgit.lib.ObjectInserter; | import org.eclipse.jgit.lib.ObjectInserter; | ||||
import org.eclipse.jgit.lib.PersonIdent; | import org.eclipse.jgit.lib.PersonIdent; | ||||
import org.eclipse.jgit.lib.Ref; | |||||
import org.eclipse.jgit.lib.RefRename; | import org.eclipse.jgit.lib.RefRename; | ||||
import org.eclipse.jgit.lib.RefUpdate; | import org.eclipse.jgit.lib.RefUpdate; | ||||
import org.eclipse.jgit.lib.RefUpdate.Result; | import org.eclipse.jgit.lib.RefUpdate.Result; | ||||
} | } | ||||
LOGGER.error(MessageFormat.format(pattern, parameters.toArray()), t); | 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 | * Returns a RefModel for the reflog branch in the repository. If the | ||||
return user; | 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. | * Updates the reflog with the received commands. | ||||
* | * |
import com.gitblit.models.RefModel; | import com.gitblit.models.RefModel; | ||||
import com.gitblit.models.RepositoryModel; | import com.gitblit.models.RepositoryModel; | ||||
import com.gitblit.models.UserModel; | import com.gitblit.models.UserModel; | ||||
import com.gitblit.utils.CommitCache; | |||||
import com.gitblit.utils.JGitUtils; | import com.gitblit.utils.JGitUtils; | ||||
import com.gitblit.utils.RefLogUtils; | |||||
import com.gitblit.utils.StringUtils; | import com.gitblit.utils.StringUtils; | ||||
import com.gitblit.wicket.GitBlitWebSession; | import com.gitblit.wicket.GitBlitWebSession; | ||||
import com.gitblit.wicket.WicketUtils; | import com.gitblit.wicket.WicketUtils; | ||||
} | } | ||||
return; | 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(); | r.close(); | ||||
if (success) { | if (success) { | ||||
info(MessageFormat.format("Branch \"{0}\" deleted", entry.displayName)); | |||||
info(MessageFormat.format("Branch \"{0}\" deleted", branch)); | |||||
// redirect to the owning page | // redirect to the owning page | ||||
setResponsePage(getPage().getClass(), WicketUtils.newRepositoryParameter(repositoryModel.name)); | setResponsePage(getPage().getClass(), WicketUtils.newRepositoryParameter(repositoryModel.name)); | ||||
} | } | ||||
else { | else { | ||||
error(MessageFormat.format("Failed to delete branch \"{0}\"", entry.displayName)); | |||||
error(MessageFormat.format("Failed to delete branch \"{0}\"", branch)); | |||||
} | } | ||||
} | } | ||||
}; | }; |
import org.apache.wicket.markup.repeater.data.ListDataProvider; | import org.apache.wicket.markup.repeater.data.ListDataProvider; | ||||
import org.apache.wicket.model.StringResourceModel; | import org.apache.wicket.model.StringResourceModel; | ||||
import org.eclipse.jgit.lib.Repository; | import org.eclipse.jgit.lib.Repository; | ||||
import org.eclipse.jgit.transport.ReceiveCommand.Type; | |||||
import com.gitblit.Constants; | import com.gitblit.Constants; | ||||
import com.gitblit.GitBlit; | import com.gitblit.GitBlit; | ||||
changeItem.add(new Label("whenChanged", fuzzydate + ", " + df.format(changeDate))); | changeItem.add(new Label("whenChanged", fuzzydate + ", " + df.format(changeDate))); | ||||
Label changeIcon = new Label("changeIcon"); | 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"); | WicketUtils.setCssClass(changeIcon, "iconic-tag"); | ||||
} else { | } else { | ||||
WicketUtils.setCssClass(changeIcon, "iconic-upload"); | WicketUtils.setCssClass(changeIcon, "iconic-upload"); |