Azure-devops-cli-extension: Add options to create repo command to create with readme, gitignore

Created on 24 Jan 2018  路  10Comments  路  Source: Azure/azure-devops-cli-extension

Hi All,

Having the option to state whether a new repository is created with a blank readme.md and .gitignore files might be useful.

Also been able to create a repository with a branch policy would be such a time saver. Even better if you could set a global branch policy for all repositories created and apply that template to your chosen branch such as master branch...

Unless someone know of a better way of doing this via command line?

Regards

Matt

enhancement planned command enhancement

Most helpful comment

@gauravsaraIMs, apologies for the delayed response, I'm currently away on holiday in Thailand!

The issue I came across was quiet simple in nature really. We have the requirement to have multiple repos so I was looking at ways to automate the creation of the repo along with any default assets and branch policies, i.e. scaffold the repo from nothing based on your specific requirements.

At high level something that replicates the GUI operations when creating a repo manually, i.e. selecting the gitignore file type and clicking the "add readme" option.

To expand this via the CLI, I think it would be nice to be able to pull in the gitignore file from any URL, as would the readme.md file, eg. If you had a template file for the reader you could pull in from somewhere.

Hope this is useful. I will be back home next week should you wish to discuss the option further.

Cheers 馃榿

All 10 comments

Hey @bantler - we just released a new version of the extension https://github.com/Microsoft/azure-devops-cli-extension/releases/tag/20190222.7 that includes the branch policy commands that can be applied to repositories in your project. Hope this helps you!

Scoping this issue to only the first part: _"Having the option to state whether a new repository is created with a blank readme.md and .gitignore files might be useful."_

@bantler : While we are trying to build a solution for this can you try using invoke command to see if that satisfies your requirement?

Command will be something like this
az devops invoke --org https://gsaralprivate.visualstudio.com/ --area git --resource pushes --route-parameters repositoryId=21bdf19e-5b1f-4233-a1b1-b5fc86acdd82 --http-method POST --in-file D:/temp/createPush.json

Where the createPush.json will be something like this

{
    "refUpdates": [
      {
        "name": "refs/heads/master",
        "oldObjectId": "0000000000000000000000000000000000000000"
      }
    ],
    "commits": [
      {
        "comment": "Added task markdown file.",
        "changes": [
          {
            "changeType": "add",
            "item": {
              "path": "/tasks.md"
            },
            "newContent": {
              "content": "# Tasks\n\n* Item 1\n* Item 2",
              "contentType": "rawtext"
            }
          }
        ]
      }
    ]
  }

For the details on how this json is formed you can get information at
https://docs.microsoft.com/en-us/rest/api/azure/devops/git/pushes/create?view=azure-devops-rest-5.0#examples

Do let us know if this satisfies your requirement

I struggled with the same issue, not able to add readme file and .gitignore in the CLI. Hopefully this feature will be added soon

@gauravsaralMs Great to see this is been looked at and thanks for the input, i will look at this interim solution in the meantime.

@bantler : In order to make the right choice so that you can use the command without any issues we will need some inputs from your side

  1. What is the scenario you are trying to solve?
  2. How do you intend or expect this command to be? Like if you have to give a high level sketch of the desired command then what would that be?

@bantler : Gentle Ping!!!
@RaymondHartog : can you please share some information?

  1. What is the scenario you are trying to solve?
  2. How do you intend or expect this command to be? Like if you have to give a high level sketch of the desired command then what would that be?

@gauravsaraIMs, apologies for the delayed response, I'm currently away on holiday in Thailand!

The issue I came across was quiet simple in nature really. We have the requirement to have multiple repos so I was looking at ways to automate the creation of the repo along with any default assets and branch policies, i.e. scaffold the repo from nothing based on your specific requirements.

At high level something that replicates the GUI operations when creating a repo manually, i.e. selecting the gitignore file type and clicking the "add readme" option.

To expand this via the CLI, I think it would be nice to be able to pull in the gitignore file from any URL, as would the readme.md file, eg. If you had a template file for the reader you could pull in from somewhere.

Hope this is useful. I will be back home next week should you wish to discuss the option further.

Cheers 馃榿

@bantler : we discussed this internally and it seems like git import is a better solution for you.
you can maintain some template getting started repos and after creating the project/ repo you can import the starting files from there.

Import is present at : az repos import -h

Let us know your thougths!!!

Closing this for now, as the recommendation here is to keep template repos and then use then with import in getting started scenario.

Let us know in case this does not meets your requirements.

Was this page helpful?
0 / 5 - 0 ratings