0

How can we commit data from unpackaged folder to the repo folder.

I have master repo created and want to commit the changes to the metadata which is retrieved via retrieve cli command. If I try to add from unpackaged folder, I get an error directory not in repo error.

-MasterRepo
 --classes
  ---testclass1
 --workflows
  ---Oppurtuity.workflow
  ---Case.workflow

-Unpackaged Folder 
 --classes
  ---testclass1
 --workflows
  ---Oppurtuity.workflow
  ---Case.workflow
2

Git

Git only can version files that are inside the root directory of the repository. The tree you depict suggests that your "Unpackaged Folder" pull is a separate directory hierarchy outside of your repository. You'll need to move the retrieved files into your MasterRepo directory tree before you'll be able to git add them.

Git by itself is not really a file manager. You can do things like git rm and git mv to execute a file system operation (delete and move, respectively), but they don't work on files that aren't already under version control (they're just conveniences). You'll need to use your OS's file manager to integrate your trees.

Salesforce DX and Retrievals

If you're using the force:source:retrieve command for working with new-format source code against a sandbox, all you need to do is execute

sfdx force:source:retrieve -x package.xml -u david@ktema.org

within your SFDX project folder, which should also be your Git folder. SFDX automatically routes all pulled metadata to the right subfolders of the project and overwrites any changed files with new versions. Immediately after performing the pull, you can run

git status

to see what's been updated before you construct your commit.

If you're using the SFDX Metadata API commands, the behavior is a little bit different, but can still handle much of the merge for you.

Running these commands from the root of your SFDX project will pull and convert MDAPI source, integrating it into your project tree:

sfdx force:mdapi:retrieve -u your@user.name -k package.xml --retrievetargetdir mdapi
unzip -d mdapi/src mdapi/unpackaged.zip
sfdx force:mdapi:convert -r mdapi/src

Note that unlike force:source:retrieve, the force:mdapi:convert command won't overwrite existing files - it'll rename them with .dup and you'll have to manually resolve which version you want.

If you are not using new-format source code, you'll only be working with force:mdapi:retrieve. This command

Uses Metadata API to retrieve a .zip of XML files that represent metadata from the targeted org.

Hence, you'll still have to deal with unzipping the package and merging the results into your Git tree. The details of how to do so will depend on what archive tool you have available and your operating system. Alternately, you might choose to use a different Metadata API tool. The details would really belong to another question once you've had a chance to explore.

|improve this answer|||||
  • I am using sfdx force:mdapi:retrieve but I am not using dx yet. – ab0369 Jan 2 '19 at 4:22
  • OK. I'm not sure what your specific issue is. Does the information above help? – David Reed Jan 2 '19 at 4:32
  • I am trying to retrieve the metadata that is modified in the sandbox and commit to git. Will the retrieve command override existing files if the code is not in new-format ? When you say new-format is it the same as mentioned by @sfdcfox below ? – ab0369 Jan 2 '19 at 4:48
  • If you use SFDX to retrieve Metadata API source, you'll have to manage unzipping the file and copying the retrieved files into your source tree. – David Reed Jan 2 '19 at 14:52
  • Got it. We are trying to create a master repo for the first time. We are trying to get most of the metadata into repo. Do you think will there be any conflict if we convert the code into new-format and not use sfdx for development. developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/… – ab0369 Jan 2 '19 at 15:10
1

All files and directories to be committed to a git repo must be in the repo. In terms of DX, you're expected to have each package in the same directory, like this:

+ base-meta
  + objects ...
+ package1-meta
  + objects ...
sfdx-project.json

As an example, see the Easy Spaces repo. It contains four directories that contain various types of metadata in an organized manner.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.