PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0
Showing posts with label commit. Show all posts
Showing posts with label commit. Show all posts

Wednesday, July 13, 2022

[FIXED] What is the method of referencing version control commit tags and hashes in Redmine?

 July 13, 2022     commit, hash, messages, redmine, tags     No comments   

Issue

What is the method of referencing version control commit tags and hashes in Redmine?

ie in commit messages, and in the notes and wikis.


Solution

From http://www.redmine.org/projects/redmine/wiki/RedmineTextFormatting :

  • Link to an issue: #124
  • Link to a changeset: r758
  • Link to a changeset with a non-numeric hash: commit:c6f4d0fd


Answered By - marapet
Answer Checked By - David Goodson (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Tuesday, July 12, 2022

[FIXED] How do you undo your Add Line Break in Git Commit Message?

 July 12, 2022     commit, git, message     No comments   

Issue

I know how to add multiple lines already in my git commit message.

I am using:

git commit -m "
>Text here... 
>[Accidental Enter Key]

However, what if I mistakenly pressed the Enter button and I want to go back to the previous line? Is there such a way?


Solution

GNU Readline editing is wacky at times. In the situation when you've accidentally hit Enter in the middle of a quoted string in Bash, just hit Ctrl-C. The part of the command line before the last Enter is preserved in the history. You just lose the very last line: anything you typed since the last Enter. After this Ctrl-C, you can recall the line and edit it. This time around, you can move the cursor back through the quote: you can back-space the unwanted multi-line parts to join them into a single line.

$ echo "abc
> oops hit Enter, didn't mean to
> oops, I did it again!^C

Now up arrow:

$ echo "abc
oops hit Enter, didn't mean to_  <- cursor is here (lost the last line)
^
 `- no > characters here now, and you can move the cursor left
    to just before the "oops" and hit backspace to merge it with
    the "abc.

It's not clear why Readline is so inconsistent in this way: why there is the > mode for continuing the line, but then normal editing when you recall that; maybe there is a way to configure away this unfriendly > stupidity. I think it exists for the sake of newbies: the > prompt is a loud and clear signal indicating "hey, you have an unbalanced quote or something, and so I'm prompting you for more input". Still, that's no reason not to allow the user to at least backspace past the >.

In any case, in this situation you can always just complete the commit with the unintended message and then immediately do a

$ git commit --amend -m "corect message"   # oops
$ git commit --amend -m "correc message"   # darn
$ git commit --amend -m "correct message!"

Finally, get a keyboard which doesn't have a tiny backspace key, and a huge Enter key right under it! Those idiotic keyboards are the main reason you accidentally hit Enter: precisely when you want to backspace to fix something that is wrong. Imagine if gas pedals were right next to the brake!



Answered By - Kaz
Answer Checked By - Katrina (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] How to reference issue (gitlab, github) at the beginning of the message with "$ git commit"?

 July 12, 2022     commit, commit-message, git, message     No comments   

Issue

I am trying to reference some issue at my commit message, I want to put the issue identifier at the beginning of the message, but also using some text editor to edit commit message (the command is git commit).

When I try this #10 my message here that line is ignored, because at editor all lines starting with # are ignored.

I already see this question here but here all examples only refence the issue in the middle of the message, or if it's at the beginning of the message all examples uses:

git commit -m "#10 my message"

How can I use the text editor and start the commit message with my issue identifier? I thinking maybe there is something like // or ! to inform that this line should not be ignored.


Solution

Don't forget the git config core.commentchar "*" that I mentioned here: you can change what character ignores a line in a commit message.

You can even change it just for your commit command:

git -c core.commantchar="*" commit ...


Answered By - VonC
Answer Checked By - Robin (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Monday, July 11, 2022

[FIXED] How to modify the git -commit messages using jenkins?

 July 11, 2022     commit, git, github, jenkins, message     No comments   

Issue

I'm using a Jenkins server to check build & merge on master. Now I want to implement it so that it modifies the commit messages with a custom string. Concrete example : let's say I made 3 commits on a branch ;

commit #3
commit #2
commit #1

What I want to do is change these messages so that they look like

ISSUE-XX commit #3
ISSUE-XX commit #2
ISSUE-XX commit #1

where XX will be completed by the user triggering the jenkins build. Is there any way to do this? I haven't been able to find an answer online so far.

I already thought about implementing git-hooks but that's not exactly what I want and I also thought about automatic rebasing but I don't quite understand it.


Solution

Solved with squashing, using the script below. The solution squashes the last (NUMBER_OF_COMMITS) into a single one given as a Build Parameter and sets a custom commit message, also given as a build parameter.

    ::Rebasing to modify commit messages

    :: Reset the current branch to the commit just before the last 12:
    git reset --hard HEAD~%NUMBER_OF_COMMITS%

    :: HEAD@{1} is where the branch was just before the previous command.
    :: This command sets the state of the index to be as it would just
    :: after a merge from that commit:
    git merge --squash HEAD@{1}

    :: Commit those squashed changes.
    git commit -m "%ISSUE%"


Answered By - Petrut Jianu
Answer Checked By - David Marino (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] How to use the default git commit message after resolving merge conflicts?

 July 11, 2022     commit, conflict, git, merge, message     No comments   

Issue

After doing a merge and resolving conflicts, is there an "easy" way to just accept the default generated commit message from the command line? One of our developers will resolve all the conflicts, and then do a git commit -m"Merge Commit" which replaces the generated commit message that listed all the conflict files. I would like to have a different flag that would just take the current file without modification. I know there is a -F or --file= option, but that requires knowing the file name all the time.

Thank you


Solution

Obviously the "right" answer here is to get your developer to follow correct practice for your team when generating merge commits. Note that the behavior you want used to be the default, and that only recently has git begun demanding "human generated" commit messages for merges. That was for a reason, and it wasn't so that developers would short-circuit the process with a meaningless message.

Maybe the developer is generating merge commits when s/he should be rebasing instead?

That said, the merge commit is the output of git fmt-merge-msg, to which you would have to feed the parents of the merge commit.



Answered By - Andy Ross
Answer Checked By - Timothy Miller (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Wednesday, January 5, 2022

[FIXED] How to use transactions in cakephp?

 January 05, 2022     cakephp, cakephp-3.0, commit, php, transactions     No comments   

Issue

I'm trying to use commit with setConnection() but it doesn't work... I have no idea how to make the transaction work in cakephp

I found in the documentation this: https://book.cakephp.org/3.0/en/orm/database-basics.html#using-transactions

but I could not implement... The problem is that I want to guarantee the save of two entities:

$this->Users->save($user) and $clientTable->save($client)

this is my code:

public function register()
    {
        $locator = TableRegistry::getTableLocator();
        $clientTable = $locator->get("Clients");

        $user = $this->Users->newEntity();
        $client = $clientTable->newEntity();

        if ($this->request->is('post')) {

            $request = $this->request->getData();

            $user = $this->Users->patchEntity($user, $request);

            $result = false;
            // begin()
            if ($this->Users->save($user)) {
                $request['user_id'] = $user->id;
                $client = $clientTable->patchEntity($client, $request);
                if ($clientTable->save($client)) {
                    $result = true;
                }
            }
            if ($result) {
                // commit()
                $this->Flash->success(__('The user has been registered.'));

                return $this->redirect([
                    'action' => 'login'
                ]);
            } else {
                // rollback()
            }

        $this->Flash->error(__('The user could not be registered. Please, try again.'));
        }
        $this->set(compact('$user'));
    }


Solution

You can try the following code:

try {
    $this->Users->getConnection()->begin();
    $this->Users->saveOrFail($userEntity, ['atomic' => false]);
    $this->Users->getConnection()->commit();

} catch(\Cake\ORM\Exception\PersistenceFailedException $e) {
    $this->Users->getConnection()->rollback();
}


Answered By - Dhananjay Kyada
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Older Posts Home
View mobile version

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
All Comments
Atom
All Comments

Copyright © PHPFixing