"use strict";(self.webpackChunkfi=self.webpackChunkfi||[]).push([[7823],{3905:(e,t,n)=>{n.d(t,{Zo:()=>u,kt:()=>d});var r=n(7294);function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function i(e){for(var t=1;t=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var l=r.createContext({}),p=function(e){var t=r.useContext(l),n=t;return e&&(n="function"==typeof e?e(t):i(i({},t),e)),n},u=function(e){var t=p(e.components);return r.createElement(l.Provider,{value:t},e.children)},m="mdxType",c={inlineCode:"code",wrapper:function(e){var t=e.children;return r.createElement(r.Fragment,{},t)}},h=r.forwardRef((function(e,t){var n=e.components,a=e.mdxType,o=e.originalType,l=e.parentName,u=s(e,["components","mdxType","originalType","parentName"]),m=p(n),h=a,d=m["".concat(l,".").concat(h)]||m[h]||c[h]||o;return n?r.createElement(d,i(i({ref:t},u),{},{components:n})):r.createElement(d,i({ref:t},u))}));function d(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var o=n.length,i=new Array(o);i[0]=h;var s={};for(var l in t)hasOwnProperty.call(t,l)&&(s[l]=t[l]);s.originalType=e,s[m]="string"==typeof e?e:a,i[1]=s;for(var p=2;p{n.r(t),n.d(t,{assets:()=>l,contentTitle:()=>i,default:()=>c,frontMatter:()=>o,metadata:()=>s,toc:()=>p});var r=n(7462),a=(n(7294),n(3905));const o={title:"Submitting merge requests"},i="Submitting merge requests for review",s={unversionedId:"mr",id:"mr",title:"Submitting merge requests",description:"This tutorial aims to show you how to follow basic git workflow and submit changes",source:"@site/pb071/mr.md",sourceDirName:".",slug:"/mr",permalink:"/pb071/mr",draft:!1,editUrl:"https://gitlab.com/mfocko/blog/tree/main/pb071/mr.md",tags:[],version:"current",lastUpdatedAt:1694109735,formattedLastUpdatedAt:"Sep 7, 2023",frontMatter:{title:"Submitting merge requests"},sidebar:"autogeneratedBar",previous:{title:"Practice exam C",permalink:"/pb071/pexam/cams"}},l={},p=[{value:"Tutorial",id:"tutorial",level:2},{value:"Step #1 - Starting from the clean repository",id:"step-1---starting-from-the-clean-repository",level:3},{value:"Step #2 - Create new branch",id:"step-2---create-new-branch",level:3},{value:"Step #3 - Do the assignment",id:"step-3---do-the-assignment",level:3},{value:"Step #4 - Commit and upload the changes to GitLab",id:"step-4---commit-and-upload-the-changes-to-gitlab",level:3},{value:"Step #5 - Creating a merge request manually",id:"step-5---creating-a-merge-request-manually",level:3},{value:"Step #6 - Set assignees",id:"step-6---set-assignees",level:3},{value:"Step #7 - Return to default branch",id:"step-7---return-to-default-branch",level:3}],u={toc:p},m="wrapper";function c(e){let{components:t,...n}=e;return(0,a.kt)(m,(0,r.Z)({},u,n,{components:t,mdxType:"MDXLayout"}),(0,a.kt)("h1",{id:"submitting-merge-requests-for-review"},"Submitting merge requests for review"),(0,a.kt)("p",null,"This tutorial aims to show you how to follow basic git workflow and submit changes\nthrough ",(0,a.kt)("em",{parentName:"p"},"Merge Requests")," for review."),(0,a.kt)("p",null,"The rudimentary idea behind aims for changes to be present on a separate branch\nthat is supposedly ",(0,a.kt)("em",{parentName:"p"},"merged")," into the default branch. Till then changes can be reviewed\non ",(0,a.kt)("em",{parentName:"p"},"Merge Request")," and additional changes may be made based on the reviews. Once\nthe changes satisfy requirements, the merge request is merged."),(0,a.kt)("h2",{id:"tutorial"},"Tutorial"),(0,a.kt)("blockquote",null,(0,a.kt)("p",{parentName:"blockquote"},"Use this tutorial only for bonus assignments ",(0,a.kt)("strong",{parentName:"p"},"made by your tutors")," or in case\nyou need to make up for the absence.")),(0,a.kt)("h3",{id:"step-1---starting-from-the-clean-repository"},"Step #1 - Starting from the clean repository"),(0,a.kt)("p",null,"In your repository (either locally or on aisa) type ",(0,a.kt)("inlineCode",{parentName:"p"},"git status")," and check if your\nrepository is clean and you are present on the main branch (",(0,a.kt)("inlineCode",{parentName:"p"},"master"),", ",(0,a.kt)("inlineCode",{parentName:"p"},"main")," or\n",(0,a.kt)("inlineCode",{parentName:"p"},"trunk"),"). If you do not know what your default branch is, it is probably ",(0,a.kt)("inlineCode",{parentName:"p"},"master"),"\nand you should not be on any other branch."),(0,a.kt)("p",null,"Output of the command should look like this:"),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre"},"aisa$ git status\nOn branch master # Or main or trunk.\nYour branch is up to date with 'origin/master'.\n\nnothing to commit, working tree clean\n")),(0,a.kt)("blockquote",null,(0,a.kt)("p",{parentName:"blockquote"},"In case you are on different branch or there are uncommitted changes,\n",(0,a.kt)("strong",{parentName:"p"},"do not continue!!!")," Clean your repository (commit the changes or discard\nthem), before you continue.")),(0,a.kt)("h3",{id:"step-2---create-new-branch"},"Step #2 - Create new branch"),(0,a.kt)("p",null,"In your repository write command:"),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre"},"aisa$ git checkout -b BRANCH\nSwitched to a new branch 'BRANCH'\n")),(0,a.kt)("p",null,"Instead of ",(0,a.kt)("inlineCode",{parentName:"p"},"BRANCH")," use some reasonable name for the branch. For example if you\nare working on the seminar from 3rd week, name the branch ",(0,a.kt)("inlineCode",{parentName:"p"},"seminar-03"),"."),(0,a.kt)("h3",{id:"step-3---do-the-assignment"},"Step #3 - Do the assignment"),(0,a.kt)("p",null,"Download the skeleton for the seminar assignment, extract and program. For example\nif you are working on 3rd seminar, you can do so by:"),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre"},"aisa$ wget https://www.fi.muni.cz/pb071/seminars/seminar-03/pb071-seminar-03.zip\naisa$ unzip pb071-seminar-03.zip\n# Now you should have directory 'seminar-03'.\naisa$ rm pb071-seminar-03.zip\naisa$ cd seminar-03\n# You can work on the assignment.\n")),(0,a.kt)("h3",{id:"step-4---commit-and-upload-the-changes-to-gitlab"},"Step #4 - Commit and upload the changes to GitLab"),(0,a.kt)("p",null,"The same way you ",(0,a.kt)("em",{parentName:"p"},"add")," and ",(0,a.kt)("em",{parentName:"p"},"commit")," files for the homework assignments, you do for\nthe seminar."),(0,a.kt)("p",null,"Now you can upload the changes to GitLab. ",(0,a.kt)("inlineCode",{parentName:"p"},"git push")," is not enough, since repository\non GitLab does not know your new branch. You can solve this by adding arguments:"),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre"},"aisa$ git push origin BRANCH\n...\nremote: To create a merge request for BRANCH, visit:\nremote: https://gitlab.fi.muni.cz/login/pb071/merge_requests/new?merge_request%5Bsource_branch%5D=BRANCH\n...\n")),(0,a.kt)("p",null,"In the output you should have a link for creating a merge request. If you see this\nlink, open it and skip next step."),(0,a.kt)("h3",{id:"step-5---creating-a-merge-request-manually"},"Step #5 - Creating a merge request manually"),(0,a.kt)("ol",null,(0,a.kt)("li",{parentName:"ol"},"Open your repository on GitLab."),(0,a.kt)("li",{parentName:"ol"},"On the left panel click on ",(0,a.kt)("em",{parentName:"li"},"Merge Requests"),"."),(0,a.kt)("li",{parentName:"ol"},"Click on ",(0,a.kt)("em",{parentName:"li"},"New Merge Request"),"."),(0,a.kt)("li",{parentName:"ol"},"In ",(0,a.kt)("em",{parentName:"li"},"Source branch")," select ",(0,a.kt)("inlineCode",{parentName:"li"},"login/pb071")," and ",(0,a.kt)("inlineCode",{parentName:"li"},"BRANCH"),", which you created."),(0,a.kt)("li",{parentName:"ol"},"In ",(0,a.kt)("em",{parentName:"li"},"Target branch")," select ",(0,a.kt)("inlineCode",{parentName:"li"},"login/pb071")," and your default branch you have seen\nin the output of the first command. (most likely ",(0,a.kt)("inlineCode",{parentName:"li"},"master"),")"),(0,a.kt)("li",{parentName:"ol"},"Click on ",(0,a.kt)("em",{parentName:"li"},"Compare branches and continue"),".")),(0,a.kt)("h3",{id:"step-6---set-assignees"},"Step #6 - Set assignees"),(0,a.kt)("p",null,"On the page that is opened, please check at the top that you are creating merge\nrequest ",(0,a.kt)("strong",{parentName:"p"},"from")," your new branch ",(0,a.kt)("strong",{parentName:"p"},"to")," your default branch (one of ",(0,a.kt)("inlineCode",{parentName:"p"},"master"),", ",(0,a.kt)("inlineCode",{parentName:"p"},"main"),"\nor ",(0,a.kt)("inlineCode",{parentName:"p"},"trunk"),")."),(0,a.kt)("p",null,"Then in the field ",(0,a.kt)("em",{parentName:"p"},"Assignees")," set your tutors based on the seminar group. You can\nuse login for a quick look up."),(0,a.kt)("p",null,"In the end click on ",(0,a.kt)("em",{parentName:"p"},"Submit merge request"),"."),(0,a.kt)("h3",{id:"step-7---return-to-default-branch"},"Step #7 - Return to default branch"),(0,a.kt)("p",null,"Homework assignments can be submitted only from branches specified in the rules\nfor the course. Because of that, before you do anything else, you should switch\nback to your default branch."),(0,a.kt)("p",null,"First of all, same as in step #1, check that your repository is clean with ",(0,a.kt)("inlineCode",{parentName:"p"},"git status"),".\nFor the sake of safety, do not continue without clean repository. Then with command\n",(0,a.kt)("inlineCode",{parentName:"p"},"git checkout BRANCH")," switch to your default branch ",(0,a.kt)("inlineCode",{parentName:"p"},"BRANCH"),"."),(0,a.kt)("p",null,"If you do not know which branch is your default, try ",(0,a.kt)("inlineCode",{parentName:"p"},"git branch")," that outputs all branches in your repository. Default branch is typically ",(0,a.kt)("inlineCode",{parentName:"p"},"master"),", but can\nbe ",(0,a.kt)("inlineCode",{parentName:"p"},"main")," or ",(0,a.kt)("inlineCode",{parentName:"p"},"trunk"),"."),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre"},"aisa$ git status\n# Check if repository is clean\n\n# If you know, what is your default branch, you can skip next command.\naisa$ git branch\n# Find the default branch in the list; should be one of the `master`, `main` or\n# `trunk` and you should not have more than one of those.\n# In case the list clears the terminal and you cannot see shell prompt, you can\n# press `q` to quit the pager.\n\naisa$ git checkout master\n")),(0,a.kt)("hr",null),(0,a.kt)("p",null,"Adapted from: ",(0,a.kt)("a",{parentName:"p",href:"https://www.fi.muni.cz/~xlacko1/pb071/mr.html"},"https://www.fi.muni.cz/~xlacko1/pb071/mr.html")))}c.isMDXComponent=!0}}]);