GithubHelp home page GithubHelp logo

hg-resource's Introduction

Mercurial Resource

Tracks the commits in a Mercurial repository.

Source Configuration

  • uri: Required. The location of the repository.

  • branch: The branch to track, defaults to default.

  • omit_branch: If set to true, the entire repository history will be cloned. Defaults to false.

  • private_key: Optional. Private key to use when pulling/pushing. Example:

    private_key: |
      -----BEGIN RSA PRIVATE KEY-----
      MIIEowIBAAKCAQEAtCS10/f7W7lkQaSgD/mVeaSOvSF9ql4hf/zfMwfVGgHWjj+W
      <Lots more text>
      DWiJL+OFeg9kawcUL6hQ8JeXPhlImG6RTUffma9+iGQyyBMCGd1l
      -----END RSA PRIVATE KEY-----
    
  • paths: Optional. If specified (as a list of regular expressions), only changes to the specified files will yield new versions from check.

  • ignore_paths: Optional. The inverse of paths; changes to the specified files are ignored.

    Note that if you want to push commits that change these files via a put, the commit will still be "detected", as check and put both introduce versions. To avoid this you should define a second resource that you use for commits that change files that you don't want to feed back into your pipeline - think of one as read-only (with ignore_paths) and one as write-only (which shouldn't need it).

  • skip_ssl_verification: Optional. Skips git ssl verification by exporting GIT_SSL_NO_VERIFY=true.

  • tag_filter: Optional. If specified, the resource will only detect commits that have a tag matching the specified regular expression.

  • revset_filter: Optional. If specified, the resource will only detect commits that matches the specified revset expression (see https://www.mercurial-scm.org/repo/hg/help/revsets).

Example

Resource configuration for a private repo:

resources:
- name: source-code
  type: hg
  source:
    uri: ssh://[email protected]/my-repo
    branch: default
    private_key: |
      -----BEGIN RSA PRIVATE KEY-----
      MIIEowIBAAKCAQEAtCS10/f7W7lkQaSgD/mVeaSOvSF9ql4hf/zfMwfVGgHWjj+W
      <Lots more text>
      DWiJL+OFeg9kawcUL6hQ8JeXPhlImG6RTUffma9+iGQyyBMCGd1l
      -----END RSA PRIVATE KEY-----

Pushing local commits to the repo:

- get: some-other-repo
- put: source-code
  params: {repository: some-other-repo}

Behavior

check: Check for new commits.

The repository is cloned (or pulled if already present), and any commits made after the given version are returned. If no version is given, the ref for the head of the branch is returned.

Any commits that contain the string [ci skip] will be ignored. This allows you to commit to your repository without triggering a new version.

in: Clone the repository, at the given ref.

Clones the repository to the destination, and locks it down to a given ref. Returns the resulting ref as the version.

Subrepositories are initialized and updated recursively, as Mercurial does by default.

out: Push to a repository.

Push the checked-out reference to the source's URI and branch. If a fast-forward for the branch is not possible and the rebase parameter is not provided, the push will fail. The tag option can only be used in combination with rebase, as tagging in Mercurial involves adding a new commit. Specifically, out clones the repository and strips all descendants of the checked-out reference, and then adds the tag commit as the new tip.

Parameters

  • repository: Required. The path of the repository to push to the source.

  • rebase: Optional. If pushing fails with non-fast-forward, continuously attempt rebasing and pushing.

  • tag: Optional, requires rebase If this is set then the checked-out reference will be tagged. The value should be a path to a file containing the name of the tag.

  • tag_prefix: Optional. If specified, the tag read from the file will be prepended with this string. This is useful for adding v in front of version numbers.

Development

Prerequisites

  • golang is required - version 1.9.x is tested; earlier versions may also work.
  • docker is required - version 17.06.x is tested; earlier versions may also work.
  • godep is used for dependency management of the golang packages.

Running the tests

The tests have been embedded with the Dockerfile; ensuring that the testing environment is consistent across any docker enabled platform. When the docker image builds, the test are run inside the docker container, on failure they will stop the build.

Run the tests with the following command:

docker build -t hg-resource --target tests --build-arg base_image=paketobuildpacks/run-jammy-base:latest .

Contributing

Please make all pull requests to the master branch and ensure tests pass locally.

hg-resource's People

Contributors

andreasf avatar cdevienne avatar chenbh avatar cirocosta avatar fydon avatar goonzoid avatar harxy avatar pivotal-bin-ju avatar pvaramballypivot avatar s2hc-johan avatar taylorsilva avatar vito avatar xavierzwirtz avatar xtremerui avatar youssb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hg-resource's Issues

Resource fails with `open /root/.ssh/config: no such file or directory`

So I can't be 100% sure, but after a upgrade the other day, all our resources started failing with:

open /root/.ssh/config: no such file or directory

Looking at the change I would guess this change is the offender:

75d0270#diff-539560c8bb7f0b5eb133bea29c18badb2943d366769fff45fb33a54120bde909R54

Looking at the previous atomicSave function it looks like it actually checks for the dir and creates it if it doesn't exists.

Are we doing anything wrong since we're using root, should we run as another user, should we have the go module create the dir if necessary or should we have the directory created in the docker file instead?

Tag before pulling and rebasing

Tag should tag the current commit id of the working directory before pulling and rebasing. otherwise, manually triggering a job can lead to tagging the wrong commit.

Steps to reproduce:

  1. Create a pipeline that gets, tags and pushes
  2. Add a commit in the source repo and trigger the pipeline
  3. Increment the version resource so that another commit can be tagged
  4. Manually trigger the pipeline again.

Expected behavior:

The tip commit of the source repo should get tagged again.

Actual behavior:

Out pulls the tag commit from the destination repo. Since there is no new commit in the source repo, the old tag commit ("Added tag ... for changeset ...") is now at tip, and out tags it with the new version number.

Always including `--branch` does not allow for pulling full repository

I need to do some operations on the entire repository inside of a job. By setting the branch default if the branch option is unset, only changsets up to and including the tip of default are cloned and pulled. I need an argument to not include any branch. I can make the change, what is the preferred way to express branch(somebranch) | no-branch in the config?

Cloning with subrepositories and other vcs

Hi!

I've been trying to set-up a concourse pipeline for a project of mine, and stumbled upon a problem: I can't clone a repository, that has git subrepositories.

error: check failed with exit status '1':
abort: couldn't find git for subrepo 'XXX'
(check git is installed and in your PATH)
Error updating working directory to tip: exit status 255

I was digging around and it seems the docker image for this resource needs git, and perhaps other vcs tools.

Can this feature be added in some reasonable timeframe? I'm willing to install a custom version of hg-resource if you could provide a hint on how to do that.

Resource receiving revisions from a different branch

I explicitly set the branch that the resource should be using, which in this case is default, but other branches which I'm creating from default are ending up on a pipeline, which then fails to use it with the following error:

abort: unknown revision 'x'!
Error checking out x: exit status 255`

I think this error is from sourceRepo.GetCurrentCommitId in out.go, but I assume the problem is in check. Should the hg log calls in hg.go be using --branch to filter results to a certain branch, e.g GetLatestCommitId and GetDescendantsOf? How would I go about debugging this?

"fly execute --exclude-ignored" broken for mercurial resource #1244

cc @marco-m Moved from concourse/concourse#1244


With a pipeline using the mercurial resource

resources:
- name: concourse-native
  type: hg
  source:
    uri: https://bitbucket.com/me/myrepo
    branch: default

The checked out repo will have a directory named .hg (the equivalent of .git).

When doing a one-off build with fly execute, it will upload the whole repo history, inside the .hg directory.

If I try to avoid uploading the .hg directory with --exclude-ignored, fly prints an error message and stays stuck uploading (have to hit Ctrl-C):

 concourse-native> fly -t tutorial execute --exclude-ignored --config ci/build-task.yml
 executing build 34
 could not determine ignored files: exit status 128
   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                  Dload  Upload   Total   Spent    Left  Speed
   0     0    0     0    0     0      0      0 --:--:--  0:00:24 --:--:--     0^C

I just double-tested the exact setup but with a git repository and the .git directory is not uploaded and the upload succeeds.

  • Concourse version: 3.1.1
  • Infrastructure/IaaS: Vagrant
  • Did this used to work? First time I tried

Support username/password same way as git-resource

Hi,

I wanted to use hg-resource, using http username+tokens for authentication, but it seems that this is not really supported by this resource.

and when i tried to do:

uri: https://{{repo_hg_user}}:{{repo_hg_password}}@some-url

I actually ended up in something like:

https://"username":"password"@some-url

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.