Example #1
0
  private void execute(final ReceiveCommand cmd) {
    try {
      final RefUpdate ru = db.updateRef(cmd.getRefName());
      ru.setRefLogIdent(getRefLogIdent());
      switch (cmd.getType()) {
        case DELETE:
          if (!ObjectId.zeroId().equals(cmd.getOldId())) {
            // We can only do a CAS style delete if the client
            // didn't bork its delete request by sending the
            // wrong zero id rather than the advertised one.
            //
            ru.setExpectedOldObjectId(cmd.getOldId());
          }
          ru.setForceUpdate(true);
          status(cmd, ru.delete(walk));
          break;

        case CREATE:
        case UPDATE:
        case UPDATE_NONFASTFORWARD:
          ru.setForceUpdate(isAllowNonFastForwards());
          ru.setExpectedOldObjectId(cmd.getOldId());
          ru.setNewObjectId(cmd.getNewId());
          ru.setRefLogMessage("push", true);
          status(cmd, ru.update(walk));
          break;
      }
    } catch (IOException err) {
      cmd.setResult(
          Result.REJECTED_OTHER_REASON,
          MessageFormat.format(JGitText.get().lockError, err.getMessage()));
    }
  }
 @Before
 public void before() throws Exception {
   repository = lookupRepository(repositoryFile);
   for (String ref : repository.getTags().keySet()) {
     RefUpdate op = repository.updateRef(ref, true);
     op.setRefLogMessage(
         "tag deleted", //$NON-NLS-1$
         false);
     // we set the force update in order
     // to avoid having this rejected
     // due to minor issues
     op.setForceUpdate(true);
     op.delete();
   }
   revWalk = new RevWalk(repository);
 }
Example #3
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   Log.i(TAG, "onOptionsItemSelected " + item);
   switch (item.getItemId()) {
     case android.R.id.home:
       return homewardsWith(this, manageRepoIntent(repo()));
     case DELETE_ID:
       try {
         RefUpdate update = repo().updateRef(tagRef.getName());
         update.setForceUpdate(true);
         // update.setNewObjectId(head);
         // update.setForceUpdate(force || remote);
         Result result = update.delete();
         Toast.makeText(this, "Tag deletion : " + result.name(), Toast.LENGTH_SHORT).show();
         finish();
       } catch (IOException e) {
         Log.e(TAG, "Couldn't delete " + revTag.getName(), e);
         throw new RuntimeException(e);
       }
       return true;
   }
   return super.onOptionsItemSelected(item);
 }