Question about custom descriptor file manipulation

We are implementing a file storage system via Stash, and what we are replacing now uses a descriptor file. This file, called deployment.xml, contains configuration information for our other processes such as documenting production transfers. Ideally, we would require the deployers to include this .xml file with every push, and we currently have a pre-receive hook implemented that will block a push if it doesn't contain it. The second, and more tricky, part is to remove the deployment.xml file from their repository, and move it to a different directory on our Linux file system. What would a good way to implement this be? A pre or post receive hook? Should we look at implementing a shell script on the back end that moves the file? Any assistance or ideas would be appreciated.

2 answers

1 vote
Adam Ahmed Atlassian Team Apr 29, 2015

If I understand you correctly, I don't think there's a good way to do that. Removing files from the repository necessarily changes the commit hash. So your options would be to either:

  1. amend the commit as soon as it's received, causing the developer who pushed it to no longer have the same code as your server has. (and pulling it will merge the commits, causing the old commit to be added back to the repository anyway - they'd have to rebase after every push).
  2. push a new commit on top of it that removes the deployment.xml file. they'd have to pull after every push. This wouldn't remove the file from history though - it'd still exist in the repository at the older commit.

Are you sure you don't want to copy the XML file to a new directory? Is it necessary that you remove the file from the repository?

Something like 

git show master:deployment.xml > /other/dir/deployment.xml

should do the trick for copying.

Sorry for the late response. Thank you for your answer, it started a conversation with my team about how we wanted to process this information. If I wanted to use that git command in a java pre-receive hook similar to this other resource I've been using:    how would I do that?

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 06, 2018 in Bitbucket

Upgrade Best Practices

Hello! My name is Mark Askew and I am a Premier Support Engineer for products Bitbucket Server/Data Center, Fisheye & Crucible. Today, I want to bring the discussion that Jennifer, Matt, and ...

1,915 views 7 10
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you