script to capture the package name from the commit message - powershell

I am trying to set up a GitLab ci pipeline to delete packages, the pipeline will trigger only after the merge request is approved, and the package name is captured from the $CI_COMMIT_MESSAGE and pass it to the delete command to delete the package.
But the $CI_COMMIT_MESSAGE which I have given during push (decomm-xxx) is been added with a few extra lines (Merge branch 'ipl1' into 'Condition'
decomm-zzz
See Merge request lkjdscjnjsdcdsnjkjkj") after the MR is approved and merged.
How exactly can I capture the package name from the $CI_COMMIT_MESSAGE which I originally gave (decomm-xxx), I need to print only the text after "decomm-" but I am not able to print it.
Any help on this would be much appreciated, thank you.
Below is the screenshot's which I tried.

There's maybe a couple ways to do this:
Stop gitlab from adding the extra text
Write a script to accommodate the extra text added when merging an MR
Change the commit message
To stop GitLab from adding the extra text, expand the dropdown under the merge button. This will let you edit the merge commit message:
Write a more reliable script
Alternatively, you can write a script to reliably extract the text you need. Using regex is probably the most reasonable way to do this.
script:
- pattern='decomm-([A-z]+)' # adjust this pattern to suit your needs
- '[[ "$CI_COMMIT_MESSAGE" =~ $pattern ]]'
- CIMessage="${BASH_REMATCH[1]}"
- echo "$CIMessage" # zzz

Related

GitHub Actions workflow syntax not working as expected

I have a GitHub workflow that is triggered when files according to the
pattern **/abc** are modified / created.
As far as I understand it, this means that whenever a:
File that is in some subfolder of a folder that starts with abc or
Any file that starts with abc
is modified, the GH action should be triggered.
However, the workflow is even triggered when I e.g. create a file repository/aaa/test_abc
However, to my understanding, the file repository/aaa/test_abc does not correspond to the pattern **/abc**
Do I
Misunderstand GH actions syntax or is it
A Bug in GH actions?
You need to escape the / with a \ for the pattern to work.
Using '**\/abc**' will resolve the problem.
Most of the time, the filter pattern cheat sheet for the Github Documentation helps to configure the paths, but in that specific case it wasn't detailed.

How to ignore a file in GitHub CODEOWNERS while still having a wildcard

I'm hoping this is a really simple answer I've overlooked, but I have a repo on GitHub using CODEOWNERS and would like to do the following:
# Default reviewers except for the subsequently listed things:
* #global-owner1 #global-owner2
# Some other owners
/packages/something/ #octocat
/packages/another/ #doctocat
# PRs _only_ affecting the "Some other owners" paths will
# also include a change to the CHANGELOG.md, but I don't want
# #global-owner1 or #global-owner2 to be added on those PRs.
CHANGELOG.md
Is there a way to "ignore" the CHANGELOG.md file in this way?
The file is read backwards, and the first match ends the search. So it seems like you don't need that last line, as the "some other owners paths" will get hit first.

Changing the commit message while grafting a large number of changesets using Mercurial

I need to graft a large number (thousands) of small changesets from branch A to branch B - but need to alter the commit message in the process.
The message change needs to look roughly like this:
"Ref XXX: Fixed foo and bar" -> "GRAFT: Ref YYY: Fixed foo and bar".
In other words, I need to prepend "GRAFT:" and change a reference number. If I can't make these replacements directly with Mercurial, I could create the new commit messages all in advance then make a script to apply each new message during its respective graft. Happily, Mercurial allows editing commit messages during grafting, with the -e argument:
https://www.mercurial-scm.org/repo/hg/help/graft
The problem is that this pops up a text editor for each changeset for me to make the change manually. There doesn't seem to be a way to amend the message in a programmatic way, or just to provide an entirely new message, at the comment line. Given the size of operation, using the editor each time isn't plausible.
My last option would be to use the text editor with some sort of AutoIt/Macro script to enter the right things in the places at the right times - but the thought of needing to resort to this is frankly making me feel a bit ill.
Save me from this ugly fate.
Thanks in advance.
A possible workaround is to specify the use of a shell script in lieu of an editor. For example:
#!/bin/sh
sed -e '1,1s/^/GRAFT: /' -i "$1"
We're making use of the fact that with -i, sed will do an in-place edit. Don't forget to make the shell script executable. Then you can run
hg graft --config ui.editor=/path/to/prepend-graft.sh -e -r <revision>
where /path/to/prepend-graft.sh is the path of the aforementioned shell script.
Changing a number may require code that's more complex than a sed script, but would follow the same approach.

HEAD and master denotations using github

I have been fumbling around on github, and now with some help I have managed to make my branch the local master. however, I get these lines that i guess are tracking where things have been changed. But I don't want them!! I really just want my current files to become the new master as they are.
What exactly are these lines for? And how do I suppress them?
<<<<<<< HEAD
=======
>>>>>>> master
Those lines signal merge conflicts in Git.
When you do a merge, git is generally good at automatically working out how to merge files together, however there are some cases where it cannot - for example, when both branches are adding to the same kind of area in the same file, you get a merge conflict.
In these cases, those lines will be drawn around the boundary of the conflict. The section above the ======= belongs to the HEAD ref (or whatever is displayed after <<<<<<<). The section below belongs to the master ref (or whatever is displayed after >>>>>>>).
It's up to you to delete these lines and make the according edit to the code. If you only want to take what is on the HEAD ref in the final version of the code (post-merge), then you delete everything below the ====== line - and visa versa if you want to only take what is on the master branch. Of course, you can also take both versions of the code by just removing the markers.
You can see the git manual for more information.

Perforce - only for experts?

I use P4V client. I just want to do basic tasks; I don't want to use the command line and become an expert at Perforce. The simple task I'm trying to accomplish is to copy the description and file list of a submitted changelist. Is there any way to do this basic task?
Using the command line does not make one an expert.
p4 describe <changelist> was a whole lot shorter to type than your question :)
There is a two step process in p4v, where you open the submitted changelist view and:
select the description of the changelist in question and copy it, then paste it to your destination.
open the node of the changelist and select the file names that you would like, copy those and paste them to your destination.
note that you can also print the changelist including submitted files from this view, if a hard copy is what you are after.
I agree that that p4win was better suited for this task, and that the command line solution is a bit less tedious.